Class: DJB::TinyDNS::Resource
- Inherits:
-
Object
- Object
- DJB::TinyDNS::Resource
- Defined in:
- lib/djb/tinydns.rb
Instance Attribute Summary collapse
-
#fqdn ⇒ Object
readonly
Returns the value of attribute fqdn.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#ttl ⇒ Object
readonly
Returns the value of attribute ttl.
Instance Method Summary collapse
- #encode ⇒ Object
-
#initialize(args) ⇒ Resource
constructor
A new instance of Resource.
- #to_s ⇒ Object
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
#fqdn ⇒ Object (readonly)
Returns the value of attribute fqdn.
89 90 91 |
# File 'lib/djb/tinydns.rb', line 89 def fqdn @fqdn end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
88 89 90 |
# File 'lib/djb/tinydns.rb', line 88 def @timestamp end |
#ttl ⇒ Object (readonly)
Returns the value of attribute ttl.
87 88 89 |
# File 'lib/djb/tinydns.rb', line 87 def ttl @ttl end |
Instance Method Details
#encode ⇒ Object
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_s ⇒ Object
104 105 106 |
# File 'lib/djb/tinydns.rb', line 104 def to_s return self.class::Sigil + @fields.join(":") end |