Class: Dnsruby::RR::HINFO

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

Overview

Class for DNS Host Information (HINFO) resource records.

Constant Summary collapse

ClassValue =

:nodoc: all

nil
TypeValue =

:nodoc: all

Types::HINFO

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, #from_hash, 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

#cpuObject

The CPU type for this RR.



24
25
26
# File 'lib/dnsruby/resource/HINFO.rb', line 24

def cpu
  @cpu
end

#osObject

The operating system type for this RR.



26
27
28
# File 'lib/dnsruby/resource/HINFO.rb', line 26

def os
  @os
end

Class Method Details

.decode_rdata(msg) ⇒ Object

:nodoc: all



65
66
67
68
69
# File 'lib/dnsruby/resource/HINFO.rb', line 65

def self.decode_rdata(msg) #:nodoc: all
  cpu = msg.get_string
  os = msg.get_string
  return self.new([cpu, os])
end

Instance Method Details

#encode_rdata(msg, canonical = false) ⇒ Object

:nodoc: all



60
61
62
63
# File 'lib/dnsruby/resource/HINFO.rb', line 60

def encode_rdata(msg, canonical=false) #:nodoc: all
  msg.put_string(@cpu)
  msg.put_string(@os)
end

#from_data(data) ⇒ Object

:nodoc: all



28
29
30
# File 'lib/dnsruby/resource/HINFO.rb', line 28

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

#from_string(input) ⇒ Object

:nodoc: all



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/dnsruby/resource/HINFO.rb', line 32

def from_string(input) #:nodoc: all
  strings = TXT.parse(input)
  cpu = ""
  os = ""
  if (strings.length == 1)
    cpu, os = input.split(" ")
  else
    cpu = strings[0]
    os = strings[1]
  end
  cpu.sub!(/^\"/, "")
  @cpu = cpu.sub(/\"$/, "")
  os.sub!(/^\"/, "")
  @os = os.sub(/\"$/, "")
end

#rdata_to_stringObject

:nodoc: all



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/dnsruby/resource/HINFO.rb', line 48

def rdata_to_string #:nodoc: all
  if (defined?@cpu)
    temp = []
    [@cpu, @os].each {|str|
      output = TXT.display(str)
      temp.push("\"#{output}\"")
    }
    return temp.join(' ')
  end
  return ''
end