Class: DNS::Zonefile::Zone

Inherits:
Object
  • Object
show all
Defined in:
lib/dns/zonefile.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entries, alternate_origin = nil) ⇒ Zone

Returns a new instance of Zone.



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
# File 'lib/dns/zonefile.rb', line 28

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

#originObject (readonly)

Returns the value of attribute origin.



25
26
27
# File 'lib/dns/zonefile.rb', line 25

def origin
  @origin
end

#recordsObject (readonly)

Returns the value of attribute records.



26
27
28
# File 'lib/dns/zonefile.rb', line 26

def records
  @records
end

#soaObject (readonly)

Returns the value of attribute soa.



25
26
27
# File 'lib/dns/zonefile.rb', line 25

def soa
  @soa
end

Instance Method Details

#records_of(kl) ⇒ Object



67
68
69
# File 'lib/dns/zonefile.rb', line 67

def records_of(kl)
	@records.select{|r| r.instance_of? kl}
end