Class: PhoneSites::GsmArena::PhoneModel

Inherits:
PhoneModel show all
Extended by:
Memoist
Defined in:
lib/phone_sites/gsm_arena/phone_model.rb

Constant Summary collapse

ITEMS_PER_PAGE =
40

Instance Method Summary collapse

Methods inherited from PhoneModel

#initialize

Methods inherited from Base

#initialize, parseable_attributes

Constructor Details

This class inherits a constructor from PhoneSites::PhoneModel

Instance Method Details

#infoObject


26
27
28
# File 'lib/phone_sites/gsm_arena/phone_model.rb', line 26

def info
  ModelInfoResponse.new.perform(URI.join(PhoneSites::GsmArena::BASE_URL, url).to_s)
end

#parse(data, attr_name) ⇒ Object


11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/phone_sites/gsm_arena/phone_model.rb', line 11

def parse(data, attr_name)
  case attr_name
  when :name
    data.children.last.text
  when :url
    data.attribute("href").text
  when :picture_url
    data.css("img").attribute("src").text
  when :description
    data.css("img").attribute("title").text
  else
    raise NotImplementedError
  end
end