Class: Stew::Store::Sale

Inherits:
Object
  • Object
show all
Defined in:
lib/stew/store/sale.rb

Overview

A single sale in the Steam Store

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Sale

Returns a new instance of Sale.



5
6
7
# File 'lib/stew/store/sale.rb', line 5

def initialize(node)
  @node = node
end

Instance Method Details

#app_idObject



23
24
25
# File 'lib/stew/store/sale.rb', line 23

def app_id
  @node.to_s.match(/tab_row_Discounts_([0-9]+)/)[1].to_i
end

#nameObject



9
10
11
# File 'lib/stew/store/sale.rb', line 9

def name
  @node.at_css("div.tab_desc").at_css("h4").content
end

#original_priceObject



17
18
19
20
21
# File 'lib/stew/store/sale.rb', line 17

def original_price
  possible_price = Stew.money(self.class.content_or_nil(@node.at_css("div.tab_price").at_css('strike')))
  return price if possible_price.fractional == 0
  possible_price
end

#priceObject



13
14
15
# File 'lib/stew/store/sale.rb', line 13

def price
  Stew.money @node.at_css("div.tab_price").children.last.content.strip
end