Class: Rex::Struct2::CStruct_Values

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/struct2/c_struct.rb

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ CStruct_Values

Returns a new instance of CStruct_Values.



12
13
14
# File 'lib/rex/struct2/c_struct.rb', line 12

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



30
31
32
33
34
35
36
# File 'lib/rex/struct2/c_struct.rb', line 30

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



16
17
18
19
20
# File 'lib/rex/struct2/c_struct.rb', line 16

def [](*args)
	o = @obj[*args]
	return if !o
	return o.value
end

#[]=(*args) ⇒ Object



22
23
24
25
26
# File 'lib/rex/struct2/c_struct.rb', line 22

def []=(*args)
	o = @obj[*args[0 .. -2]]
	return if !o
	o.value = args[-1]
end