Class: DJB::TinyDNS::Resource

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

Direct Known Subclasses

A, CNAME, Generic, Host, MX, NS::Base, PTR, SOA, TXT

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Resource

Returns a new instance of Resource.



91
92
93
94
95
96
97
98
# File 'lib/djb/tinydns.rb', line 91

def initialize(args)
    @args = { 'timestamp' => '', 'ttl' => '' }
    @args.update(args)
    @args.default('')

    @fields = Array.new
    @fqdn   = args['fqdn']
end

Instance Attribute Details

#fqdnObject (readonly)

Returns the value of attribute fqdn.



89
90
91
# File 'lib/djb/tinydns.rb', line 89

def fqdn
  @fqdn
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



88
89
90
# File 'lib/djb/tinydns.rb', line 88

def timestamp
  @timestamp
end

#ttlObject (readonly)

Returns the value of attribute ttl.



87
88
89
# File 'lib/djb/tinydns.rb', line 87

def ttl
  @ttl
end

Instance Method Details

#encodeObject



100
101
102
# File 'lib/djb/tinydns.rb', line 100

def encode
    data.gsub(/[^0-9a-zA-Z]/) { |m| sprintf("\\%.3o", m[0]) }
end

#to_sObject



104
105
106
# File 'lib/djb/tinydns.rb', line 104

def to_s
    return self.class::Sigil + @fields.join(":")
end