Class: DirectoryEntry

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

Constant Summary collapse

BYTES_EACH =
16

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject

Returns the value of attribute name.



613
614
615
# File 'lib/ruby-doom.rb', line 613

def name
  @name
end

#offsetObject

Returns the value of attribute offset.



613
614
615
# File 'lib/ruby-doom.rb', line 613

def offset
  @offset
end

#sizeObject

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_sObject



643
644
645
# File 'lib/ruby-doom.rb', line 643

def to_s
  @offset.to_s + "," + @size.to_s + "," + @name
end

#writeObject



622
623
624
# File 'lib/ruby-doom.rb', line 622

def write
  Codec.encode("ll8", [@offset, @size, @name])
end