Class: Itch::Game
Overview
Represents a single game and sub-resources
Constant Summary
collapse
- THEME_DATA =
/GameEdit\.ThemeEditor\((.*)\),\$\('#game_appearance_editor_widget_/.freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
#exclude_inspection, #inspect, #pretty_print_instance_variables
#require_auth, #with_login
Constructor Details
#initialize(agent, map, id = nil, name: nil) ⇒ Game
Returns a new instance of Game.
19
20
21
22
23
24
25
26
|
# File 'lib/itch/game.rb', line 19
def initialize(agent, map, id = nil, name: nil)
raise Error, "Game ID or name is required" if id.nil? && name.nil?
@agent = agent
@map = map
load_game_info(id, name)
end
|
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
15
16
17
|
# File 'lib/itch/game.rb', line 15
def id
@id
end
|
#name ⇒ Object
Returns the value of attribute name.
15
16
17
|
# File 'lib/itch/game.rb', line 15
def name
@name
end
|
#page_url ⇒ Object
Returns the value of attribute page_url.
15
16
17
|
# File 'lib/itch/game.rb', line 15
def page_url
@page_url
end
|
Instance Method Details
#css ⇒ Object
34
35
36
|
# File 'lib/itch/game.rb', line 34
def css
theme["css"]
end
|
#css=(css_data) ⇒ Object
42
43
44
45
46
|
# File 'lib/itch/game.rb', line 42
def css=(css_data)
new_theme = theme
new_theme["css"] = css_data
self.theme = new_theme
end
|
#reviews ⇒ Object
52
53
54
|
# File 'lib/itch/game.rb', line 52
def reviews
Reviews.new(@agent, @id)
end
|
#reward(id) ⇒ Object
56
57
58
|
# File 'lib/itch/game.rb', line 56
def reward(id)
rewards.find { |reward| reward.id == id }
end
|
#rewards ⇒ Object
48
49
50
|
# File 'lib/itch/game.rb', line 48
def rewards
Rewards.new(@agent, @id)
end
|
#theme ⇒ Object
28
29
30
31
32
|
# File 'lib/itch/game.rb', line 28
def theme
JSON.parse(theme_data)["theme"]
rescue StandardError
{}
end
|
#theme=(theme_data) ⇒ Object
38
39
40
|
# File 'lib/itch/game.rb', line 38
def theme=(theme_data)
@agent.post edit_theme_url, theme_post_data(theme_data)
end
|