Class: ChromeData::CollectionRequest

Inherits:
BaseRequest show all
Defined in:
lib/chrome_data/collection_request.rb

Direct Known Subclasses

Division, Model, Style

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from BaseRequest

build_request, client, endpoint_uri, find_elements, #initialize, make_request, request, wsdl_body

Constructor Details

This class inherits a constructor from ChromeData::BaseRequest

Instance Attribute Details

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/chrome_data/collection_request.rb', line 3

def id
  @id
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/chrome_data/collection_request.rb', line 3

def name
  @name
end

Class Method Details

.parse_response(response) ⇒ Object

Find elements matching class name and instantiate them using their id attribute and text



12
13
14
15
16
# File 'lib/chrome_data/collection_request.rb', line 12

def parse_response(response)
  find_elements(name.split('::').last.downcase, response).map do |e|
    new id: e.attr('id').to_i, name: e.text
  end
end

.request_nameObject



6
7
8
9
# File 'lib/chrome_data/collection_request.rb', line 6

def request_name
  # Cheap-o inflector
  "get#{name.split('::').last}s"
end