Class: RecordStore::Provider::NS1::ApiAnswer
- Inherits:
-
Object
- Object
- RecordStore::Provider::NS1::ApiAnswer
- Defined in:
- lib/record_store/provider/ns1.rb
Instance Attribute Summary collapse
-
#record_id ⇒ Object
Returns the value of attribute record_id.
-
#rrdata ⇒ Object
Returns the value of attribute rrdata.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
- .from_full_api_answer(type:, record_id:, answer:) ⇒ Object
- .from_short_api_answer(type:, record_id:, answer:) ⇒ Object
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(type:, record_id:, rrdata:) ⇒ ApiAnswer
constructor
A new instance of ApiAnswer.
- #rrdata_string ⇒ Object
Constructor Details
#initialize(type:, record_id:, rrdata:) ⇒ ApiAnswer
Returns a new instance of ApiAnswer.
29 30 31 32 33 |
# File 'lib/record_store/provider/ns1.rb', line 29 def initialize(type:, record_id:, rrdata:) @type = type @record_id = record_id @rrdata = rrdata end |
Instance Attribute Details
#record_id ⇒ Object
Returns the value of attribute record_id.
27 28 29 |
# File 'lib/record_store/provider/ns1.rb', line 27 def record_id @record_id end |
#rrdata ⇒ Object
Returns the value of attribute rrdata.
27 28 29 |
# File 'lib/record_store/provider/ns1.rb', line 27 def rrdata @rrdata end |
#type ⇒ Object
Returns the value of attribute type.
27 28 29 |
# File 'lib/record_store/provider/ns1.rb', line 27 def type @type end |
Class Method Details
.from_full_api_answer(type:, record_id:, answer:) ⇒ Object
8 9 10 |
# File 'lib/record_store/provider/ns1.rb', line 8 def from_full_api_answer(type:, record_id:, answer:) ApiAnswer.new(type: type, record_id: record_id, rrdata: answer['answer']) end |
.from_short_api_answer(type:, record_id:, answer:) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/record_store/provider/ns1.rb', line 12 def from_short_api_answer(type:, record_id:, answer:) rrdata_fields = case type when 'SPF', 'TXT' [answer] when 'SRV' priority, weight, port, host = answer.split [priority.to_i, weight.to_i, port.to_i, Record.ensure_ends_with_dot(host)] else answer.split end ApiAnswer.new(type: type, record_id: record_id, rrdata: rrdata_fields) end |
Instance Method Details
#id ⇒ Object
39 40 41 |
# File 'lib/record_store/provider/ns1.rb', line 39 def id [record_id, type, *rrdata] end |
#rrdata_string ⇒ Object
35 36 37 |
# File 'lib/record_store/provider/ns1.rb', line 35 def rrdata_string rrdata.join(' ') end |