Class: Elf::Value
- Inherits:
-
Object
- Object
- Elf::Value
- Defined in:
- lib/elf/value.rb
Direct Known Subclasses
Class, DataEncoding, Dynamic::Type, File::Type, Indexes, Machine, OsAbi, Section::Flags, Section::Type, Section::Type::GNU, Section::Type::ProcARM, Section::Type::SunW, SunW::Capabilities::Hardware1::I386, SunW::Capabilities::Hardware1::Sparc, SunW::Capabilities::Software1, SunW::Capabilities::Tag, Symbol::Binding, Symbol::Binding::GNU, Symbol::Type, Symbol::Type::GNU, Symbol::Visibility
Defined Under Namespace
Classes: OutOfBound, Unknown
Instance Attribute Summary collapse
-
#desc ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute desc.
-
#mnemonic ⇒ Object
readonly
Returns the value of attribute mnemonic.
-
#val ⇒ Object
(also: #to_i)
readonly
Returns the value of attribute val.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(val, params) ⇒ Value
constructor
A new instance of Value.
Constructor Details
#initialize(val, params) ⇒ Value
Returns a new instance of Value.
43 44 45 46 47 |
# File 'lib/elf/value.rb', line 43 def initialize(val, params) @val = val @mnemonic = params[0].to_s @desc = params[1] end |
Instance Attribute Details
#desc ⇒ Object (readonly) Also known as: to_s
Returns the value of attribute desc.
49 50 51 |
# File 'lib/elf/value.rb', line 49 def desc @desc end |
#mnemonic ⇒ Object (readonly)
Returns the value of attribute mnemonic.
49 50 51 |
# File 'lib/elf/value.rb', line 49 def mnemonic @mnemonic end |
#val ⇒ Object (readonly) Also known as: to_i
Returns the value of attribute val.
49 50 51 |
# File 'lib/elf/value.rb', line 49 def val @val end |
Class Method Details
.[](idx) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/elf/value.rb', line 57 def Value.[](idx) return @enums[idx] if @enums[idx] # If the class has defined special ranges, handle them; a # special range is a range of values for which unknown values # are allowed (because they are bound to specific usage we don't # know about — where on the other hand unknown values outside of # these ranges are frown upon); different type of values have # different special ranges, each with its own base name, so # leave that to be decided by the class itself. if self.const_defined?("SpecialRanges") self::SpecialRanges.each_pair do |base, range| return self::Unknown.new(idx, sprintf("%s+%07x", base, idx-range.first)) if range.include? idx end end raise OutOfBound.new(idx) end |
.each(&block) ⇒ Object
103 104 105 |
# File 'lib/elf/value.rb', line 103 def Value.each(&block) @enums.each_value(&block) end |
.from_string(str) ⇒ Object
76 77 78 79 80 81 82 83 84 |
# File 'lib/elf/value.rb', line 76 def Value.from_string(str) str = str.downcase each do |value| return value if value.mnemonic.downcase == str end return nil end |
.has_key?(idx) ⇒ Boolean
86 87 88 |
# File 'lib/elf/value.rb', line 86 def Value.has_key?(idx) @enums.has_key?(idx) end |
Instance Method Details
#==(other) ⇒ Object
53 54 55 |
# File 'lib/elf/value.rb', line 53 def ==(other) self.class == other.class and @val == other.to_i end |