Class: Elf::Utilities::OffsetTable
- Inherits:
-
Object
- Object
- Elf::Utilities::OffsetTable
- Defined in:
- lib/elf/utils/offsettable.rb
Defined Under Namespace
Classes: InvalidIndex
Instance Method Summary collapse
- #[](idx) ⇒ Object
-
#initialize(content, separator) ⇒ OffsetTable
constructor
A new instance of OffsetTable.
- #size ⇒ Object
Constructor Details
#initialize(content, separator) ⇒ OffsetTable
Returns a new instance of OffsetTable.
29 30 31 32 |
# File 'lib/elf/utils/offsettable.rb', line 29 def initialize(content, separator) @content = content @separator = separator end |
Instance Method Details
#[](idx) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/elf/utils/offsettable.rb', line 38 def [](idx) raise InvalidIndex.new(idx, size) if idx >= size # find the first occurrence of the separator starting from the # given index endidx = @content.index(@separator, idx) return @content[idx..endidx].chomp(@separator) end |
#size ⇒ Object
34 35 36 |
# File 'lib/elf/utils/offsettable.rb', line 34 def size @content.size end |