Class: Loopiator::Models::DnsRecord
- Inherits:
-
Object
- Object
- Loopiator::Models::DnsRecord
- Defined in:
- lib/loopiator/models/dns_record.rb
Overview
Instance Attribute Summary collapse
-
#priority ⇒ Object
Returns the value of attribute priority.
-
#rdata ⇒ Object
Returns the value of attribute rdata.
-
#record_id ⇒ Object
Returns the value of attribute record_id.
-
#ttl ⇒ Object
Returns the value of attribute ttl.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(hash = nil) ⇒ DnsRecord
constructor
A new instance of DnsRecord.
- #to_h ⇒ Object
Constructor Details
#initialize(hash = nil) ⇒ DnsRecord
Returns a new instance of DnsRecord.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/loopiator/models/dns_record.rb', line 8 def initialize(hash = nil) if hash && hash.is_a?(Hash) && !hash.empty? hash.symbolize_keys! self.record_id = hash.fetch(:record_id, nil) self.type = hash.fetch(:type, "").to_s self.ttl = hash.fetch(:ttl, 3_600).to_i self.priority = hash.fetch(:priority, 0).to_i self.rdata = hash.fetch(:rdata, "").to_s end end |
Instance Attribute Details
#priority ⇒ Object
Returns the value of attribute priority.
6 7 8 |
# File 'lib/loopiator/models/dns_record.rb', line 6 def priority @priority end |
#rdata ⇒ Object
Returns the value of attribute rdata.
6 7 8 |
# File 'lib/loopiator/models/dns_record.rb', line 6 def rdata @rdata end |
#record_id ⇒ Object
Returns the value of attribute record_id.
6 7 8 |
# File 'lib/loopiator/models/dns_record.rb', line 6 def record_id @record_id end |
#ttl ⇒ Object
Returns the value of attribute ttl.
6 7 8 |
# File 'lib/loopiator/models/dns_record.rb', line 6 def ttl @ttl end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/loopiator/models/dns_record.rb', line 6 def type @type end |
Instance Method Details
#to_h ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/loopiator/models/dns_record.rb', line 20 def to_h data = { type: self.type, ttl: self.ttl, priority: self.priority, rdata: self.rdata } data[:record_id] = self.record_id if self.record_id return data end |