Class: DJB::TinyDNS::Resolver

Inherits:
Service
  • Object
show all
Defined in:
lib/djb/tinydns.rb

Instance Attribute Summary collapse

Attributes inherited from Service

#svc

Instance Method Summary collapse

Methods inherited from Service

#alarm, #continue, #down, #env, #exit, #hangup, #interrupt, #kill, #make, #once, #pause, #restart, #start, #stop, #terminate, #up

Constructor Details

#initialize(*args) ⇒ Resolver

Returns a new instance of Resolver.



34
35
36
37
# File 'lib/djb/tinydns.rb', line 34

def initialize(*args)
    super(*args)
    @lines = Array.new
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



32
33
34
# File 'lib/djb/tinydns.rb', line 32

def root
  @root
end

Instance Method Details

#add(entry) ⇒ Object Also known as: <<



43
44
45
# File 'lib/djb/tinydns.rb', line 43

def add(entry)
    @lines << entry.to_s
end

#add_reverse(args) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/djb/tinydns.rb', line 48

def add_reverse(args)
    fqdn = args['ip'].split('.').reverse[1..3].join(".")
    fqdn += '.in-addr.arpa'

    args['fqdn'] = fqdn

    add(DJB::TinyDNS::NS::DelegateFrom.new(args))
end

#fnObject



39
40
41
# File 'lib/djb/tinydns.rb', line 39

def fn
    return @root + "/root/data"
end

#to_fileObject



61
62
63
# File 'lib/djb/tinydns.rb', line 61

def to_file
    File.write(fn(), self.to_s)
end

#to_sObject



57
58
59
# File 'lib/djb/tinydns.rb', line 57

def to_s
    return @lines.join("\n")
end