Class: Vertex

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-doom.rb

Constant Summary collapse

FORMAT =
"ss"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(location = nil) ⇒ Vertex

Returns a new instance of Vertex.



457
458
459
# File 'lib/ruby-doom.rb', line 457

def initialize(location=nil)
  @location = location
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



456
457
458
# File 'lib/ruby-doom.rb', line 456

def id
  @id
end

#locationObject (readonly)

Returns the value of attribute location.



455
456
457
# File 'lib/ruby-doom.rb', line 455

def location
  @location
end

Instance Method Details

#read(bytes) ⇒ Object



460
461
462
# File 'lib/ruby-doom.rb', line 460

def read(bytes)
  @location = Point.new(*Codec.decode(FORMAT, bytes))
end

#to_sObject



466
467
468
# File 'lib/ruby-doom.rb', line 466

def to_s
  " Vertex at " + @location.to_s
end

#writeObject



463
464
465
# File 'lib/ruby-doom.rb', line 463

def write
  Codec.encode(FORMAT, [@location.x, @location.y])
end