Class: Watchmob::Smartphone
- Inherits:
-
Object
- Object
- Watchmob::Smartphone
- Defined in:
- lib/watchmob/smartphone.rb
Constant Summary collapse
- SPEC_PAGES =
[HeurekaPage, GSMArenaPage]
Instance Attribute Summary collapse
-
#aukro_page ⇒ Object
readonly
Returns the value of attribute aukro_page.
-
#spec_pages ⇒ Object
readonly
Returns the value of attribute spec_pages.
Class Method Summary collapse
Instance Method Summary collapse
- #aukro_deadline ⇒ Object
- #aukro_finished? ⇒ Boolean
- #aukro_price ⇒ Object
- #aukro_uri ⇒ Object
- #autofocus ⇒ Object
- #battery_capacity ⇒ Object
-
#initialize(aukro_page, spec_pages) ⇒ Smartphone
constructor
A new instance of Smartphone.
- #mass ⇒ Object
- #name ⇒ Object
- #stand_by ⇒ Object
- #talk_time ⇒ Object
Constructor Details
#initialize(aukro_page, spec_pages) ⇒ Smartphone
Returns a new instance of Smartphone.
31 32 33 34 |
# File 'lib/watchmob/smartphone.rb', line 31 def initialize(aukro_page, spec_pages) @aukro_page = aukro_page @spec_pages = spec_pages end |
Instance Attribute Details
#aukro_page ⇒ Object (readonly)
Returns the value of attribute aukro_page.
36 37 38 |
# File 'lib/watchmob/smartphone.rb', line 36 def aukro_page @aukro_page end |
#spec_pages ⇒ Object (readonly)
Returns the value of attribute spec_pages.
37 38 39 |
# File 'lib/watchmob/smartphone.rb', line 37 def spec_pages @spec_pages end |
Class Method Details
.find(params) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/watchmob/smartphone.rb', line 10 def self.find(params) unless params["aukro"] and params["phone"] raise ArgumentError, "I want parameters 'aukro' and 'phone', got #{params.inspect}" end aukro_page = AukroPage.new(URI.parse(params["aukro"])) spec_pages = SPEC_PAGES.map { |spec_page| begin spec_page.find(params["phone"]) rescue NotFoundError nil end }.select { |s| !s.nil? } unless spec_pages.empty? new(aukro_page, spec_pages) else raise NotFoundError, "Smartphone #{params["phone"]} <#{params["aukro"]}> was not found anywhere" end end |
Instance Method Details
#aukro_deadline ⇒ Object
51 52 53 |
# File 'lib/watchmob/smartphone.rb', line 51 def aukro_deadline @aukro_page.deadline end |
#aukro_finished? ⇒ Boolean
43 44 45 |
# File 'lib/watchmob/smartphone.rb', line 43 def aukro_finished? @aukro_page.finished? end |
#aukro_price ⇒ Object
47 48 49 |
# File 'lib/watchmob/smartphone.rb', line 47 def aukro_price @aukro_page.price end |
#aukro_uri ⇒ Object
55 56 57 |
# File 'lib/watchmob/smartphone.rb', line 55 def aukro_uri @aukro_page.uri end |
#autofocus ⇒ Object
75 76 77 |
# File 'lib/watchmob/smartphone.rb', line 75 def autofocus boolean :autofocus end |
#battery_capacity ⇒ Object
63 64 65 |
# File 'lib/watchmob/smartphone.rb', line 63 def battery_capacity average :battery_capacity end |
#mass ⇒ Object
59 60 61 |
# File 'lib/watchmob/smartphone.rb', line 59 def mass average :mass end |
#name ⇒ Object
39 40 41 |
# File 'lib/watchmob/smartphone.rb', line 39 def name @spec_pages.first.name end |
#stand_by ⇒ Object
67 68 69 |
# File 'lib/watchmob/smartphone.rb', line 67 def stand_by average :stand_by end |
#talk_time ⇒ Object
71 72 73 |
# File 'lib/watchmob/smartphone.rb', line 71 def talk_time average :talk_time end |