Class: Vertex
- Inherits:
-
Object
- Object
- Vertex
- Defined in:
- lib/ruby-doom.rb
Constant Summary collapse
- FORMAT =
"ss"
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
Instance Method Summary collapse
-
#initialize(location = nil) ⇒ Vertex
constructor
A new instance of Vertex.
- #read(bytes) ⇒ Object
- #to_s ⇒ Object
- #write ⇒ Object
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
#id ⇒ Object
Returns the value of attribute id.
456 457 458 |
# File 'lib/ruby-doom.rb', line 456 def id @id end |
#location ⇒ Object (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_s ⇒ Object
466 467 468 |
# File 'lib/ruby-doom.rb', line 466 def to_s " Vertex at " + @location.to_s end |
#write ⇒ Object
463 464 465 |
# File 'lib/ruby-doom.rb', line 463 def write Codec.encode(FORMAT, [@location.x, @location.y]) end |