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.
-
#soa ⇒ Object
readonly
Returns the value of attribute soa.
Instance Method Summary collapse
-
#initialize(entries, alternate_origin = nil) ⇒ Zone
constructor
A new instance of Zone.
- #records_of(kl) ⇒ Object
Constructor Details
#initialize(entries, alternate_origin = nil) ⇒ Zone
Returns a new instance of Zone.
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 |
# File 'lib/dns/zonefile.rb', line 27 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 case key = e.name.text_value.downcase when 'ttl' @vars[key] = e.value.text_value.to_i else @vars[key] = 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 '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 'TXT' then @records << TXT.new(@vars, e) when 'SOA' then ; 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.
24 25 26 |
# File 'lib/dns/zonefile.rb', line 24 def origin @origin end |
#records ⇒ Object (readonly)
Returns the value of attribute records.
25 26 27 |
# File 'lib/dns/zonefile.rb', line 25 def records @records end |
#soa ⇒ Object (readonly)
Returns the value of attribute soa.
24 25 26 |
# File 'lib/dns/zonefile.rb', line 24 def soa @soa end |
Instance Method Details
#records_of(kl) ⇒ Object
66 67 68 |
# File 'lib/dns/zonefile.rb', line 66 def records_of(kl) @records.select{|r| r.instance_of? kl} end |