Class: Stew::Store::App
- Inherits:
-
Object
- Object
- Stew::Store::App
- Defined in:
- lib/stew/store/app.rb
Overview
An application in the Steam Store Initialized from the contents of a web request to the Steam store app page
Instance Method Summary collapse
- #developer ⇒ Object
- #dlc? ⇒ Boolean
- #free? ⇒ Boolean
- #genres ⇒ Object
- #indie? ⇒ Boolean
-
#initialize(response) ⇒ App
constructor
A new instance of App.
- #name ⇒ Object
- #offers ⇒ Object
- #price ⇒ Object
- #publisher ⇒ Object
- #release_date ⇒ Object
- #score ⇒ Object
Constructor Details
#initialize(response) ⇒ App
Returns a new instance of App.
7 8 9 |
# File 'lib/stew/store/app.rb', line 7 def initialize(response) @document = Nokogiri::HTML(response) end |
Instance Method Details
#developer ⇒ Object
28 29 30 |
# File 'lib/stew/store/app.rb', line 28 def developer App.content_or_nil @document.at_xpath("//a[contains(@href, 'developer')]") end |
#dlc? ⇒ Boolean
40 41 42 |
# File 'lib/stew/store/app.rb', line 40 def dlc? @document.at_css("div.game_area_dlc_bubble") end |
#free? ⇒ Boolean
53 54 55 |
# File 'lib/stew/store/app.rb', line 53 def free? offers.count == 0 end |
#genres ⇒ Object
24 25 26 |
# File 'lib/stew/store/app.rb', line 24 def genres @document.css("div.glance_details").css("a").map {|node| node.content} end |
#indie? ⇒ Boolean
44 45 46 |
# File 'lib/stew/store/app.rb', line 44 def indie? genres.include? 'Indie' end |
#name ⇒ Object
15 16 17 |
# File 'lib/stew/store/app.rb', line 15 def name App.content_or_nil @document.at_css("div.apphub_AppName") end |
#offers ⇒ Object
36 37 38 |
# File 'lib/stew/store/app.rb', line 36 def offers @offers ||= AppOffers.new @document.css("div.game_area_purchase_game") end |
#price ⇒ Object
48 49 50 51 |
# File 'lib/stew/store/app.rb', line 48 def price return nil if free? first_offer_price end |
#publisher ⇒ Object
32 33 34 |
# File 'lib/stew/store/app.rb', line 32 def publisher App.content_or_nil @document.at_xpath("//a[contains(@href, 'publisher')]") end |
#release_date ⇒ Object
19 20 21 22 |
# File 'lib/stew/store/app.rb', line 19 def release_date node = @document.at_xpath("//b[.='Release Date:']") node && Date.parse(node.next.content) end |
#score ⇒ Object
11 12 13 |
# File 'lib/stew/store/app.rb', line 11 def score score_section[0] && score_from_score_section end |