Class: NominetEPP::Custom::TagListResponse

Inherits:
BasicResponse show all
Defined in:
lib/nominet-epp/responses/custom/tag_list_response.rb

Instance Method Summary collapse

Methods inherited from BasicResponse

#method, #method_missing, #respond_to?, #respond_to_missing?

Constructor Details

#initialize(response) ⇒ TagListResponse

Returns a new instance of TagListResponse.

Raises:

  • (ArgumentError)


4
5
6
7
# File 'lib/nominet-epp/responses/custom/tag_list_response.rb', line 4

def initialize(response)
  raise ArgumentError, "must be an EPP::Response" unless response.kind_of?(EPP::Response)
  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NominetEPP::BasicResponse

Instance Method Details

#namespacesObject



13
14
15
# File 'lib/nominet-epp/responses/custom/tag_list_response.rb', line 13

def namespaces
  { 'tag' => 'http://www.nominet.org.uk/epp/xml/nom-tag-1.0' }
end

#parse_infdataObject (protected)



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/nominet-epp/responses/custom/tag_list_response.rb', line 18

def parse_infdata
  tags = {}
  
  @response.data.find('//tag:infData', namespaces).each do |node|
    tag  = node.find('tag:registrar-tag').first.content.strip
    name = node.find('tag:name').first.content.strip
    handshake = node.find('tag:handshake').first.content.strip
    
    trad = node.find('tag:trad-name').first
    trad = trad && trad.content.strip
    
    tags[tag] = { 'name' => name, 'handshake' => handshake == 'Y' }
    tags[tag]['trad_name'] = trad if trad
  end
  
  tags
end

#tagsObject



9
10
11
# File 'lib/nominet-epp/responses/custom/tag_list_response.rb', line 9

def tags
  @tags ||= parse_infdata
end