Class: SteamPrices::Game

Inherits:
Object
  • Object
show all
Includes:
Updater
Defined in:
lib/steam_prices/steam_game.rb

Constant Summary

Constants included from Updater

Updater::EXCEPTIONS, Updater::GAME, Updater::PACK

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Updater

included

Constructor Details

#initialize(app_name = nil, app_id = nil, store_link = nil, logo_link = nil, date_released = nil, price = nil, original_price = nil) ⇒ Game

Returns a new instance of Game.

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
17
18
19
# File 'lib/steam_prices/steam_game.rb', line 9

def initialize(app_name = nil, app_id = nil, store_link = nil, logo_link = nil, date_released = nil, price = nil, original_price = nil)
  @app_id = app_id.to_i
  @app_name = app_name.to_s
  @store_link = store_link ||= "http://store.steampowered.com/app/12312312"
  @category = (@store_link.match(/(.*store\.steampowered\.com\/app\/[\d]+)/) ? GAME : PACK)
  @logo_link = logo_link
  @date_released = date_released
  raise ArgumentError, "Expected: Money()" if price.class.name != 'Money' && price != nil
  @price = price
  @original_price = original_price
end

Instance Attribute Details

#app_idObject (readonly)

Returns the value of attribute app_id.



6
7
8
# File 'lib/steam_prices/steam_game.rb', line 6

def app_id
  @app_id
end

#app_nameObject (readonly)

Returns the value of attribute app_name.



6
7
8
# File 'lib/steam_prices/steam_game.rb', line 6

def app_name
  @app_name
end

#categoryObject (readonly)

Returns the value of attribute category.



6
7
8
# File 'lib/steam_prices/steam_game.rb', line 6

def category
  @category
end

#date_releasedObject (readonly)

Returns the value of attribute date_released.



6
7
8
# File 'lib/steam_prices/steam_game.rb', line 6

def date_released
  @date_released
end

Returns the value of attribute logo_link.



6
7
8
# File 'lib/steam_prices/steam_game.rb', line 6

def logo_link
  @logo_link
end

#original_priceObject

Returns the value of attribute original_price.



7
8
9
# File 'lib/steam_prices/steam_game.rb', line 7

def original_price
  @original_price
end

#priceObject

Returns the value of attribute price.



7
8
9
# File 'lib/steam_prices/steam_game.rb', line 7

def price
  @price
end

#statusObject (readonly)

Returns the value of attribute status.



6
7
8
# File 'lib/steam_prices/steam_game.rb', line 6

def status
  @status
end

Returns the value of attribute store_link.



6
7
8
# File 'lib/steam_prices/steam_game.rb', line 6

def store_link
  @store_link
end

Instance Method Details

#update(currency = nil) ⇒ Object



21
22
23
24
# File 'lib/steam_prices/steam_game.rb', line 21

def update(currency = nil)
  return nil if !@app_name or @app_id == 0
  self.class.update_one(@category, @app_name, @app_id, currency)
end