Class: Nxo::NxoFile::Segment

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, address, contents) ⇒ Segment

Returns a new instance of Segment.



9
10
11
12
13
# File 'lib/nxo/nxo.rb', line 9

def initialize(name, address, contents)
  @name = name
  @address = address
  @contents = contents
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



16
17
18
# File 'lib/nxo/nxo.rb', line 16

def address
  @address
end

#contentsObject (readonly)

Returns the value of attribute contents.



17
18
19
# File 'lib/nxo/nxo.rb', line 17

def contents
  @contents
end

#nameObject (readonly)

Returns the value of attribute name.



15
16
17
# File 'lib/nxo/nxo.rb', line 15

def name
  @name
end

Instance Method Details

#[](offset, size) ⇒ Object



27
28
29
# File 'lib/nxo/nxo.rb', line 27

def [](offset, size)
  return @contents[offset, size]
end

#contains?(addr) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/nxo/nxo.rb', line 23

def contains?(addr)
  return addr >= @address && addr < @address + contents.bytesize
end

#sizeObject



19
20
21
# File 'lib/nxo/nxo.rb', line 19

def size
  @contents.bytesize
end