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
- #capsule_image ⇒ Object
- #developer ⇒ Object
- #dlc? ⇒ Boolean
- #dlc_app_id ⇒ Object
- #free? ⇒ Boolean
- #genres ⇒ Object
- #header_image ⇒ Object
- #indie? ⇒ Boolean
-
#initialize(response, id) ⇒ App
constructor
A new instance of App.
- #name ⇒ Object
- #offers ⇒ Object
- #price ⇒ Object
- #publisher ⇒ Object
- #regular_price ⇒ Object
- #release_date ⇒ Object
- #score ⇒ Object
Constructor Details
#initialize(response, id) ⇒ App
Returns a new instance of App.
9 10 11 12 |
# File 'lib/stew/store/app.rb', line 9 def initialize(response, id) @document = Nokogiri::HTML(response) @id = id end |
Instance Method Details
#capsule_image ⇒ Object
43 44 45 |
# File 'lib/stew/store/app.rb', line 43 def capsule_image "http://cdn2.steampowered.com/v/gfx/apps/#{@id}/capsule_sm_120.jpg" end |
#developer ⇒ Object
31 32 33 |
# File 'lib/stew/store/app.rb', line 31 def developer App.content_or_nil @document.at_xpath("//a[contains(@href, 'developer')]") end |
#dlc? ⇒ Boolean
51 52 53 |
# File 'lib/stew/store/app.rb', line 51 def dlc? !@document.css("div.game_area_dlc_bubble").empty? end |
#dlc_app_id ⇒ Object
55 56 57 58 59 |
# File 'lib/stew/store/app.rb', line 55 def dlc_app_id return nil unless dlc? #Close your eyes... @document.at_css("div.game_area_dlc_bubble").at_css('a').attributes['href'].value[/\d+/].to_i end |
#free? ⇒ Boolean
75 76 77 |
# File 'lib/stew/store/app.rb', line 75 def free? offers.count == 0 end |
#genres ⇒ Object
27 28 29 |
# File 'lib/stew/store/app.rb', line 27 def genres @document.css("div.glance_details").css("a").map {|node| node.content} end |
#header_image ⇒ Object
39 40 41 |
# File 'lib/stew/store/app.rb', line 39 def header_image App.src_or_nil @document.at_css('img.game_header_image') end |
#indie? ⇒ Boolean
61 62 63 |
# File 'lib/stew/store/app.rb', line 61 def indie? genres.include? 'Indie' end |
#name ⇒ Object
18 19 20 |
# File 'lib/stew/store/app.rb', line 18 def name App.content_or_nil @document.at_css("div.apphub_AppName") end |
#offers ⇒ Object
47 48 49 |
# File 'lib/stew/store/app.rb', line 47 def offers @offers ||= AppOffers.new @document.css("div.game_area_purchase_game") end |
#price ⇒ Object
65 66 67 68 |
# File 'lib/stew/store/app.rb', line 65 def price return nil if free? first_offer.price end |
#publisher ⇒ Object
35 36 37 |
# File 'lib/stew/store/app.rb', line 35 def publisher App.content_or_nil @document.at_xpath("//a[contains(@href, 'publisher')]") end |
#regular_price ⇒ Object
70 71 72 73 |
# File 'lib/stew/store/app.rb', line 70 def regular_price return nil if free? first_offer.regular_price end |
#release_date ⇒ Object
22 23 24 25 |
# File 'lib/stew/store/app.rb', line 22 def release_date node = @document.at_xpath("//b[.='Release Date:']") node && Date.parse(node.next.content) end |
#score ⇒ Object
14 15 16 |
# File 'lib/stew/store/app.rb', line 14 def score score_section[0] && score_from_score_section end |