Class: DirectoryEntry
- Inherits:
-
Object
- Object
- DirectoryEntry
- Defined in:
- lib/ruby-doom.rb
Constant Summary collapse
- BYTES_EACH =
16
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#size ⇒ Object
Returns the value of attribute size.
Instance Method Summary collapse
- #create_lump(bytes) ⇒ Object
-
#initialize(offset = nil, size = nil, name = nil) ⇒ DirectoryEntry
constructor
A new instance of DirectoryEntry.
- #read(array) ⇒ Object
- #to_s ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(offset = nil, size = nil, name = nil) ⇒ DirectoryEntry
Returns a new instance of DirectoryEntry.
614 615 616 617 618 |
# File 'lib/ruby-doom.rb', line 614 def initialize(offset=nil,size=nil,name=nil) @offset = offset @size = size @name = name end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
613 614 615 |
# File 'lib/ruby-doom.rb', line 613 def name @name end |
#offset ⇒ Object
Returns the value of attribute offset.
613 614 615 |
# File 'lib/ruby-doom.rb', line 613 def offset @offset end |
#size ⇒ Object
Returns the value of attribute size.
613 614 615 |
# File 'lib/ruby-doom.rb', line 613 def size @size end |
Instance Method Details
#create_lump(bytes) ⇒ Object
625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 |
# File 'lib/ruby-doom.rb', line 625 def create_lump(bytes) lump=nil if @name == Things::NAME lump=Things.new elsif @name == Linedefs::NAME lump=Linedefs.new elsif @name == Sidedefs::NAME lump=Sidedefs.new elsif @name == Vertexes::NAME lump=Vertexes.new elsif @name == Sectors::NAME lump=Sectors.new else lump=UndecodedLump.new(@name) end lump.read(bytes.slice(@offset, @size)) return lump end |
#read(array) ⇒ Object
619 620 621 |
# File 'lib/ruby-doom.rb', line 619 def read(array) @offset, @size, @name = Codec.decode("ll8", array) end |
#to_s ⇒ Object
643 644 645 |
# File 'lib/ruby-doom.rb', line 643 def to_s @offset.to_s + "," + @size.to_s + "," + @name end |