Class: DNS::Zonefile::Zone
- Inherits:
-
Object
- Object
- DNS::Zonefile::Zone
- Defined in:
- lib/dns/zonefile.rb
Instance Attribute Summary collapse
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Instance Method Summary collapse
-
#initialize(entries, alternate_origin = nil) ⇒ Zone
constructor
A new instance of Zone.
- #records_of(kl) ⇒ Object
- #soa ⇒ Object
Constructor Details
#initialize(entries, alternate_origin = nil) ⇒ Zone
Returns a new instance of Zone.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/dns/zonefile.rb', line 26 def initialize(entries, alternate_origin = nil) alternate_origin ||= "." @records = [] @vars = {"origin" => alternate_origin, :last_host => "."} entries.each do |e| case e.parse_type when :variable key = e.name.text_value.downcase @vars[key] = case key when "ttl" e.value.text_value.to_i else e.value.text_value end when :soa @records << SOA.new(@vars, e) when :record case e.record_type when "A" then @records << A.new(@vars, e) when "AAAA" then @records << AAAA.new(@vars, e) when "CAA" then @records << CAA.new(@vars, e) when "CNAME" then @records << CNAME.new(@vars, e) when "MX" then @records << MX.new(@vars, e) when "NAPTR" then @records << NAPTR.new(@vars, e) when "NS" then @records << NS.new(@vars, e) when "PTR" then @records << PTR.new(@vars, e) when "SRV" then @records << SRV.new(@vars, e) when "SPF" then @records << SPF.new(@vars, e) when "SSHFP" then @records << SSHFP.new(@vars, e) when "TXT" then @records << TXT.new(@vars, e) when "SOA" then # No-op else raise UnknownRecordType, "Unknown record type: #{e.record_type}" end end end end |
Instance Attribute Details
#origin ⇒ Object (readonly)
Returns the value of attribute origin.
23 24 25 |
# File 'lib/dns/zonefile.rb', line 23 def origin @origin end |
#records ⇒ Object (readonly)
Returns the value of attribute records.
24 25 26 |
# File 'lib/dns/zonefile.rb', line 24 def records @records end |
Instance Method Details
#records_of(kl) ⇒ Object
69 70 71 |
# File 'lib/dns/zonefile.rb', line 69 def records_of(kl) @records.select { |r| r.instance_of? kl } end |
#soa ⇒ Object
65 66 67 |
# File 'lib/dns/zonefile.rb', line 65 def soa records_of(SOA).first end |