Class: RecordStore::Provider::NS1::ApiAnswer

Inherits:
Object
  • Object
show all
Defined in:
lib/record_store/provider/ns1.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, record_id:, rrdata:) ⇒ ApiAnswer

Returns a new instance of ApiAnswer.



26
27
28
29
30
# File 'lib/record_store/provider/ns1.rb', line 26

def initialize(type:, record_id:, rrdata:)
  @type = type
  @record_id = record_id
  @rrdata = rrdata
end

Instance Attribute Details

#record_idObject

Returns the value of attribute record_id.



24
25
26
# File 'lib/record_store/provider/ns1.rb', line 24

def record_id
  @record_id
end

#rrdataObject

Returns the value of attribute rrdata.



24
25
26
# File 'lib/record_store/provider/ns1.rb', line 24

def rrdata
  @rrdata
end

#typeObject

Returns the value of attribute type.



24
25
26
# File 'lib/record_store/provider/ns1.rb', line 24

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
# 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]
  else
    answer.split
  end

  ApiAnswer.new(type: type, record_id: record_id, rrdata: rrdata_fields)
end

Instance Method Details

#idObject



36
37
38
# File 'lib/record_store/provider/ns1.rb', line 36

def id
  [record_id, type, *rrdata]
end

#rrdata_stringObject



32
33
34
# File 'lib/record_store/provider/ns1.rb', line 32

def rrdata_string
  rrdata.join(' ')
end