Class: DhcpsApi::DHCPS_Struct

Inherits:
FFI::Struct
  • Object
show all
Includes:
RubyStructAttrHelpers
Defined in:
lib/dhcpsapi/common.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RubyStructAttrHelpers

#dhcp_client_uid_to_mac, #ip_to_uint32, #mac_address_to_array_of_uint8, #to_string, #to_wchar_string, #uint32_to_ip, #wchar_string_length

Class Method Details

.ruby_struct_attr(func_name, *attr_names) ⇒ Object



47
48
49
50
51
# File 'lib/dhcpsapi/common.rb', line 47

def self.ruby_struct_attr(func_name, *attr_names)
  attr_names.each do |attr_name|
    define_method("#{attr_name}_as_ruby_struct_attr") { send(func_name, self[attr_name])}
  end
end

Instance Method Details

#as_ruby_structObject



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/dhcpsapi/common.rb', line 53

def as_ruby_struct
  members.inject({}) do |all, current|
    all[current] =
        if respond_to?("#{current}_as_ruby_struct_attr")
          send("#{current}_as_ruby_struct_attr")
        elsif self[current].is_a?(DHCPS_Struct)
          self[current].as_ruby_struct
        else
          self[current]
        end
    all
  end
end