Class: Fog::Parsers::DNS::Zerigo::GetZone

Inherits:
Base
  • Object
show all
Defined in:
lib/fog/zerigo/parsers/dns/get_zone.rb

Instance Attribute Summary

Attributes inherited from Base

#response

Instance Method Summary collapse

Methods inherited from Base

#attr_value, #characters, #initialize, #value

Constructor Details

This class inherits a constructor from Fog::Parsers::Base

Instance Method Details

#end_element(name) ⇒ Object



24
25
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
# File 'lib/fog/zerigo/parsers/dns/get_zone.rb', line 24

def end_element(name)
  if (@in_hosts)
    #in hosts part of response
    case name
    when 'id', 'zone-id'
      @host[name] = value.to_i
    when 'priority', 'ttl'
      @host[name] = value.to_i if value
    when 'data', 'fqdn', 'host-type', 'hostname', 'notes', 'zone-id', 'created-at', 'updated-at'
      @host[name] = value
    when 'host'
      @hosts << @host
      @host = {}
    when 'hosts'
      @response[name] = @hosts
      @in_hosts = false
    end
  else
    #in zone part of data
    case name
    when 'default-ttl', 'id', 'nx-ttl', 'hosts-count'
      @response[name] = value.to_i
    when 'created-at', 'custom-nameservers', 'custom-ns', 'domain', 'hostmaster', 'notes', 'ns1', 'ns-type', 'slave-nameservers', 'tag-list', 'updated-at', 'hosts', 'axfr-ips', 'restrict-axfr'
      @response[name] = value
    end
  end
  
end

#resetObject



8
9
10
11
12
13
# File 'lib/fog/zerigo/parsers/dns/get_zone.rb', line 8

def reset
  @host = {}
  @hosts = []
  @response = {}
  @in_hosts = false
end

#start_element(name, attrs = []) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/fog/zerigo/parsers/dns/get_zone.rb', line 15

def start_element(name, attrs = [])
  super(name, attrs)
  #look out for start of <hosts> section
  #needed as some of the tags have the same name as the parent <zone> section
  if name == 'hosts'
    @in_hosts= true
  end
end