Class: DNS::Zone::RR::HINFO

Inherits:
Record
  • Object
show all
Defined in:
lib/dns/zone/rr/hinfo.rb

Overview

`HINFO` resource record.

RFC 1035

Constant Summary collapse

REGEX_HINFO_RDATA =
%r{
  (?<cpu>(?:#{DNS::Zone::RR::REGEX_CHARACTER_STRING})){1}\s
  (?<os>(?:#{DNS::Zone::RR::REGEX_CHARACTER_STRING})){1}
}mx

Instance Attribute Summary collapse

Attributes inherited from Record

#klass, #label, #ttl

Instance Method Summary collapse

Methods inherited from Record

#general_prefix, #initialize, #load_general_and_get_rdata, #type

Constructor Details

This class inherits a constructor from DNS::Zone::RR::Record

Instance Attribute Details

#cpuObject

Returns the value of attribute cpu


10
11
12
# File 'lib/dns/zone/rr/hinfo.rb', line 10

def cpu
  @cpu
end

#osObject

Returns the value of attribute os


11
12
13
# File 'lib/dns/zone/rr/hinfo.rb', line 11

def os
  @os
end

Instance Method Details

#dumpObject


13
14
15
16
17
# File 'lib/dns/zone/rr/hinfo.rb', line 13

def dump
  parts = general_prefix
  parts << %Q{"#{cpu}" "#{os}"}
  parts.join(' ')
end

#load(string, options = {}) ⇒ Object


19
20
21
22
23
24
25
26
27
28
29
# File 'lib/dns/zone/rr/hinfo.rb', line 19

def load(string, options = {})
  rdata = load_general_and_get_rdata(string, options)
  return nil unless rdata

  captures = rdata.match(REGEX_HINFO_RDATA)
  return nil unless captures

  @cpu = captures[:cpu].scan(/#{DNS::Zone::RR::REGEX_CHARACTER_STRING}/).join
  @os = captures[:os].scan(/#{DNS::Zone::RR::REGEX_CHARACTER_STRING}/).join
  self
end