Class: Stew::Store::AppOffer

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

Overview

Represents a price of an application in the steam store

Direct Known Subclasses

AppOfferSale

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ AppOffer

Returns a new instance of AppOffer.



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

def initialize(node)
  @node = node
end

Class Method Details

.create(node) ⇒ Object



6
7
8
9
# File 'lib/stew/store/app_offer.rb', line 6

def self.create(node)
  return AppOfferSale.new(node) unless node.css('div.discount_final_price').empty?
  return AppOffer.new(node)
end

Instance Method Details

#descriptionObject



27
28
29
# File 'lib/stew/store/app_offer.rb', line 27

def description
  description_empty? ? nil : @node.at_css('p').content
end

#nameObject



31
32
33
# File 'lib/stew/store/app_offer.rb', line 31

def name
  @node.at_css('h1').content.strip.gsub('Buy ','')
end

#priceObject



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

def price
  Stew.money @node.at_css('div.game_purchase_price').content.gsub(/[\n\t\r\s]/, '')
end

#regular_priceObject



19
20
21
# File 'lib/stew/store/app_offer.rb', line 19

def regular_price
  price
end

#sale?Boolean

Returns:

  • (Boolean)


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

def sale?
  false
end