Class: Nxo::NxoFile::Segment
- Inherits:
-
Object
- Object
- Nxo::NxoFile::Segment
- Defined in:
- lib/nxo/nxo.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#contents ⇒ Object
readonly
Returns the value of attribute contents.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #[](offset, size) ⇒ Object
- #contains?(addr) ⇒ Boolean
-
#initialize(name, address, contents) ⇒ Segment
constructor
A new instance of Segment.
- #size ⇒ Object
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
#address ⇒ Object (readonly)
Returns the value of attribute address.
16 17 18 |
# File 'lib/nxo/nxo.rb', line 16 def address @address end |
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
17 18 19 |
# File 'lib/nxo/nxo.rb', line 17 def contents @contents end |
#name ⇒ Object (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
23 24 25 |
# File 'lib/nxo/nxo.rb', line 23 def contains?(addr) return addr >= @address && addr < @address + contents.bytesize end |
#size ⇒ Object
19 20 21 |
# File 'lib/nxo/nxo.rb', line 19 def size @contents.bytesize end |