Class: Dnsruby::RR::DHCID

Inherits:
Dnsruby::RR show all
Defined in:
lib/dnsruby/resource/DHCID.rb

Overview

Class for DNS DHCP ID (DHCID) resource records. RFC 4701

Constant Summary collapse

ClassValue =

:nodoc: all

nil
TypeValue =

:nodoc: all

Types::DHCID

Constants inherited from Dnsruby::RR

ClassInsensitiveTypes

Instance Attribute Summary collapse

Attributes inherited from Dnsruby::RR

#klass, #name, #rdata, #ttl, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Dnsruby::RR

#<=>, #==, #clone, create, #eql?, find_class, get_class, get_num, #hash, implemented_rrs, #init_defaults, new_from_data, new_from_hash, new_from_string, #rdlength, #sameRRset, #to_s

Instance Attribute Details

#dhcid_dataObject

The opaque rdata for DHCID



25
26
27
# File 'lib/dnsruby/resource/DHCID.rb', line 25

def dhcid_data
  @dhcid_data
end

Class Method Details

.decode_rdata(msg) ⇒ Object

:nodoc: all



49
50
51
52
# File 'lib/dnsruby/resource/DHCID.rb', line 49

def self.decode_rdata(msg) #:nodoc: all
  dhcid_data, = msg.get_bytes()
  return self.new([dhcid_data])
end

Instance Method Details

#encode_rdata(msg, canonical = false) ⇒ Object

:nodoc: all



45
46
47
# File 'lib/dnsruby/resource/DHCID.rb', line 45

def encode_rdata(msg, canonical=false) #:nodoc: all
  msg.put_bytes(@dhcid_data)
end

#from_data(data) ⇒ Object

:nodoc: all



31
32
33
# File 'lib/dnsruby/resource/DHCID.rb', line 31

def from_data(data) #:nodoc: all
  @dhcid_data,  = data
end

#from_hash(hash) ⇒ Object

:nodoc: all



27
28
29
# File 'lib/dnsruby/resource/DHCID.rb', line 27

def from_hash(hash) #:nodoc: all
  @dhcid_data = hash[:dhcid_data]
end

#from_string(input) ⇒ Object

:nodoc: all



35
36
37
38
39
# File 'lib/dnsruby/resource/DHCID.rb', line 35

def from_string(input) #:nodoc: all
  buf = input.gsub(/\n/, "")
  buf.gsub!(/ /, "")
  @dhcid_data = buf.unpack("m*").first
end

#rdata_to_stringObject

:nodoc: all



41
42
43
# File 'lib/dnsruby/resource/DHCID.rb', line 41

def rdata_to_string #:nodoc: all
  return "#{[@dhcid_data.to_s].pack("m*").gsub("\n", "")}"
end