Class: PhoneSites::GsmArena::ModelInfoResponse

Inherits:
BaseResponse
  • Object
show all
Defined in:
lib/phone_sites/gsm_arena/model_info_response.rb

Instance Method Summary collapse

Instance Method Details

#perform(url, method = 'get', options = {}) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
# File 'lib/phone_sites/gsm_arena/model_info_response.rb', line 5

def perform(url, method = 'get', options = {})
  response = super(url, method, options)
  body = Nokogiri::HTML(response.body)
  body.css('#specs-list table tr td')
      .map(&:text)
      .each_slice(2)
      .each_with_object({}) do |(key, value), hash|
    properties = normalize_property(key, value)
    hash.merge!(properties) if valid?(key)
  end
end