Class: TurboRex::MSRPC::RPCBase::Structures_Klass

Inherits:
Object
  • Object
show all
Defined in:
lib/turborex/msrpc/rpcbase.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cstruct) ⇒ Structures_Klass

Returns a new instance of Structures_Klass.



389
390
391
392
393
394
# File 'lib/turborex/msrpc/rpcbase.rb', line 389

def initialize(cstruct)
  @xrefs = []
  @value_table = {}          
  @cstruct = cstruct
  parse_struct(cstruct)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args) ⇒ Object



404
405
406
407
408
409
410
411
412
413
414
415
416
# File 'lib/turborex/msrpc/rpcbase.rb', line 404

def method_missing(m, *args)
  if m.to_s.end_with?('_Value')
    key = m.to_s.split('_Value')[0].to_sym
    @value_table[key]
  elsif @value_table.keys.map(&:downcase).include?(m.downcase)
    self.define_singleton_method(m) do
      @value_table[m]
    end
    @value_table[m]
  else
    super(m, *args)
  end
end

Instance Attribute Details

#xrefsObject

Returns the value of attribute xrefs.



387
388
389
# File 'lib/turborex/msrpc/rpcbase.rb', line 387

def xrefs
  @xrefs
end

Instance Method Details

#[](key) ⇒ Object



400
401
402
# File 'lib/turborex/msrpc/rpcbase.rb', line 400

def [](key)
  self.send key
end


418
419
420
421
422
# File 'lib/turborex/msrpc/rpcbase.rb', line 418

def link_and_xref(var_name, struct)
  self.instance_variable_set ('@'+var_name.to_s).to_sym, struct
  var = struct
  xref_from(struct) unless struct.is_a?(Array)
end

#to_sObject



396
397
398
# File 'lib/turborex/msrpc/rpcbase.rb', line 396

def to_s
  @cstruct.to_s
end

#xref_from(cstruct) ⇒ Object



424
425
426
# File 'lib/turborex/msrpc/rpcbase.rb', line 424

def xref_from(cstruct)
  cstruct.xrefs << self
end