Module: DNS::Zonefile::ZonefileGrammar::Zone1

Defined in:
lib/dns/zonefile/parser.rb

Instance Method Summary collapse

Instance Method Details

#entriesObject



46
47
48
49
50
# File 'lib/dns/zonefile/parser.rb', line 46

def entries
  elements[0].elements.select { |e| e.to_s !~ /\A\s*(;.*)?\z|\A\z/; } +
    [soa] +
    elements[-1].elements.select { |e| e.to_s !~ /\A\s*(;.*)?\z|\A\z/; }
end

#originObject



34
35
36
# File 'lib/dns/zonefile/parser.rb', line 34

def origin
  soa.origin.host.to_s
end

#rrObject



42
43
44
# File 'lib/dns/zonefile/parser.rb', line 42

def rr
  elements[-1].elements.select { |e| e.to_s !~ /\A\s*([;$].*)?\z|\A\z/; }
end

#to_sObject



38
39
40
# File 'lib/dns/zonefile/parser.rb', line 38

def to_s
  text_value
end

#variablesObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/dns/zonefile/parser.rb', line 23

def variables
  @variables ||= begin
    raw = elements[0].elements.select { |e| e.to_s =~ /^\$/ }
    variables = {}
    raw.each do |e|
      variables[e.name.text_value.to_s] = e.value.text_value.to_s
    end
    variables
  end
end