Class: Base
- Inherits:
-
Object
- Object
- Base
- Defined in:
- lib/elfcat/base.rb
Direct Known Subclasses
FileHeader, ProgramHeader, SectionName, SectionTable, StringTable
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#debug ⇒ Object
readonly
Returns the value of attribute debug.
Instance Method Summary collapse
- #[](_name) ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #method_missing(_method) ⇒ Object
- #parse_slice(_address, _length) ⇒ Object
- #parse_struct(_struct, _resource, _element_count, _element_size) ⇒ Object
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(_method) ⇒ Object
9 10 11 |
# File 'lib/elfcat/base.rb', line 9 def method_missing _method return @data[_method][:data] end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
2 3 4 |
# File 'lib/elfcat/base.rb', line 2 def data @data end |
#debug ⇒ Object (readonly)
Returns the value of attribute debug.
2 3 4 |
# File 'lib/elfcat/base.rb', line 2 def debug @debug end |
Instance Method Details
#[](_name) ⇒ Object
13 14 15 |
# File 'lib/elfcat/base.rb', line 13 def [](_name) return @data[_name] end |
#parse_slice(_address, _length) ⇒ Object
34 35 36 |
# File 'lib/elfcat/base.rb', line 34 def parse_slice _address, _length return $resource.slice(_address, _length).split(/\x0/).dup end |
#parse_struct(_struct, _resource, _element_count, _element_size) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/elfcat/base.rb', line 21 def parse_struct _struct, _resource, _element_count, _element_size _element_count.times do |i| st = Hash.new struct_address = i * _element_size _struct.each do |k, v| st[k] = Util.concatenate(_resource, struct_address + v[0], v[1]) end @data[i] = st.dup end end |