module Sashite::CGN::PromotableIntoActors

Constants

PATTERN

Public Class Methods

dump(io) click to toggle source
# File lib/sashite/cgn/promotable_into_actors.rb, line 29
def self.dump io
  raise ArgumentError unless dumpable? io

  actors = io[0..-2].map {|a| GameplayIntoBase64.dump a }
  actors << Actor.dump(io.last)
  actors.join(',')
end
dumpable?(io) click to toggle source
# File lib/sashite/cgn/promotable_into_actors.rb, line 22
def self.dumpable? io
  io.is_a?(Array) &&
  io.length == io.uniq.length &&
  io[0..-2].all? {|i| GameplayIntoBase64.dumpable? i } &&
  Actor.dumpable?(io.last)
end
load(io) click to toggle source
# File lib/sashite/cgn/promotable_into_actors.rb, line 14
def self.load io
  raise ArgumentError unless loadable? io

  io.split(',').map do |value|
    Actor.loadable?(value) ? Actor.load(value) : GameplayIntoBase64.load(value)
  end
end
loadable?(io) click to toggle source
# File lib/sashite/cgn/promotable_into_actors.rb, line 9
def self.loadable? io
  io.match("^#{PATTERN}$") &&
  io.split(',').uniq.join(',') == io
end