Class: PlayStation::Game

Inherits:
Object
  • Object
show all
Defined in:
app/consumers/play_station/game.rb

Overview

This model describes playstation store game

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_json = {}) ⇒ Game


22
23
24
25
26
27
28
29
30
31
# File 'app/consumers/play_station/game.rb', line 22

def initialize(raw_json = {})
  @id           = raw_json['id']
  @name         = raw_json['name']
  @description  = raw_json['long_desc']
  @release_date = Date.parse(raw_json['release_date'])
  find_best_background_or_poster(raw_json)
  find_screenshoots(raw_json)
  product_desc = raw_json['default_sku']
  find_prices(product_desc) if product_desc.present?
end

Instance Attribute Details

#descriptionObject (readonly)

Description of game, contains small amount of html


10
11
12
# File 'app/consumers/play_station/game.rb', line 10

def description
  @description
end

#idObject (readonly)

Id of game in playstation store


12
13
14
# File 'app/consumers/play_station/game.rb', line 12

def id
  @id
end

#nameObject (readonly)

Title of game


6
7
8
# File 'app/consumers/play_station/game.rb', line 6

def name
  @name
end

#poster_urlObject (readonly)

Url to poster image


18
19
20
# File 'app/consumers/play_station/game.rb', line 18

def poster_url
  @poster_url
end

#priceObject (readonly)

Current price of game. Nil if game is not published


8
9
10
# File 'app/consumers/play_station/game.rb', line 8

def price
  @price
end

#ps_plus_priceObject (readonly)

Price of game if user have ps plus membership. It might be nil


16
17
18
# File 'app/consumers/play_station/game.rb', line 16

def ps_plus_price
  @ps_plus_price
end

#release_dateObject (readonly)

Relase date of game


14
15
16
# File 'app/consumers/play_station/game.rb', line 14

def release_date
  @release_date
end

#screenshootsObject (readonly)

Array of screenshoots urls


20
21
22
# File 'app/consumers/play_station/game.rb', line 20

def screenshoots
  @screenshoots
end

Instance Method Details

#background_urlObject

Url to image that can be used for background. If nil then it returns poster_url


44
45
46
# File 'app/consumers/play_station/game.rb', line 44

def background_url
  @background_url || @poster_url
end

#published?Boolean

Is game published


34
35
36
# File 'app/consumers/play_station/game.rb', line 34

def published?
  Date.current >= @release_date
end

#urlObject

Game store url


39
40
41
# File 'app/consumers/play_station/game.rb', line 39

def url
  "https://store.playstation.com/#!/en-pl/games/cid=#{@id}"
end