Class: Rex::Struct2::CStruct_Values
- Inherits:
-
Object
- Object
- Rex::Struct2::CStruct_Values
- Defined in:
- lib/rex/struct2/c_struct.rb
Instance Method Summary collapse
- #[](*args) ⇒ Object
- #[]=(*args) ⇒ Object
-
#initialize(obj) ⇒ CStruct_Values
constructor
A new instance of CStruct_Values.
-
#method_missing(sym, *args) ⇒ Object
this one is for HD, the whiniest girl around…
Constructor Details
#initialize(obj) ⇒ CStruct_Values
Returns a new instance of CStruct_Values.
11 12 13 |
# File 'lib/rex/struct2/c_struct.rb', line 11 def initialize(obj) @obj = obj end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
this one is for HD, the whiniest girl around… allow for like v.field = whatever
29 30 31 32 33 34 35 |
# File 'lib/rex/struct2/c_struct.rb', line 29 def method_missing(sym, *args) if sym.to_s[-1] == "="[0] return self[sym.to_s[0 .. -2]] = args[0] else return self[sym.to_s] end end |
Instance Method Details
#[](*args) ⇒ Object
15 16 17 18 19 |
# File 'lib/rex/struct2/c_struct.rb', line 15 def [](*args) o = @obj[*args] return if !o return o.value end |
#[]=(*args) ⇒ Object
21 22 23 24 25 |
# File 'lib/rex/struct2/c_struct.rb', line 21 def []=(*args) o = @obj[*args[0 .. -2]] return if !o o.value = args[-1] end |