Class: WolfRpg::RouteCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/wolfrpg/route.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, args) ⇒ RouteCommand

Returns a new instance of RouteCommand.



28
29
30
31
# File 'lib/wolfrpg/route.rb', line 28

def initialize(id, args)
  @id = id
  @args = args
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



26
27
28
# File 'lib/wolfrpg/route.rb', line 26

def args
  @args
end

#idObject

Returns the value of attribute id.



25
26
27
# File 'lib/wolfrpg/route.rb', line 25

def id
  @id
end

Class Method Details

.create(coder) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/wolfrpg/route.rb', line 3

def self.create(coder)
  # Read all data for this movement command from file
  id = coder.read_byte
  args = Array.new(coder.read_byte)
  args.each_index do |i|
    args[i] = coder.read_int
  end
  coder.verify(TERMINATOR)

  #TODO Create proper route command
  return RouteCommand.new(id, args)
end

Instance Method Details

#dump(coder) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/wolfrpg/route.rb', line 16

def dump(coder)
  coder.write_byte(@id)
  coder.write_byte(@args.size)
  @args.each do |arg|
    coder.write_int(arg)
  end
  coder.write(TERMINATOR)
end