Class: Stew::Store::App

Inherits:
Object
  • Object
show all
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

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

#developerObject



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

Returns:

  • (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

Returns:

  • (Boolean)


53
54
55
# File 'lib/stew/store/app.rb', line 53

def free?
  offers.count == 0
end

#genresObject



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

Returns:

  • (Boolean)


44
45
46
# File 'lib/stew/store/app.rb', line 44

def indie?
  genres.include? 'Indie'
end

#nameObject



15
16
17
# File 'lib/stew/store/app.rb', line 15

def name
  App.content_or_nil @document.at_css("div.apphub_AppName")
end

#offersObject



36
37
38
# File 'lib/stew/store/app.rb', line 36

def offers
  @offers ||= AppOffers.new @document.css("div.game_area_purchase_game")
end

#priceObject



48
49
50
51
# File 'lib/stew/store/app.rb', line 48

def price
  return nil if free?
  first_offer_price
end

#publisherObject



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_dateObject



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

#scoreObject



11
12
13
# File 'lib/stew/store/app.rb', line 11

def score
  score_section[0] && score_from_score_section
end