Class: Itch::GameMap
- Inherits:
-
Object
- Object
- Itch::GameMap
- Includes:
- RequireAuth, SimpleInspect
- Defined in:
- lib/itch/game_map.rb
Overview
Map game names to itch ids
Could be handled via API, but would require user API keys or oauth
Instance Method Summary collapse
- #find(id) ⇒ Object
- #find!(id) ⇒ Object
- #find_by_name(name) ⇒ Object
- #find_by_name!(name) ⇒ Object
-
#initialize(agent) ⇒ GameMap
constructor
A new instance of GameMap.
- #map ⇒ Object
Methods included from RequireAuth
Methods included from SimpleInspect
#exclude_inspection, #inspect, #pretty_print_instance_variables
Constructor Details
#initialize(agent) ⇒ GameMap
Returns a new instance of GameMap.
16 17 18 |
# File 'lib/itch/game_map.rb', line 16 def initialize(agent) @agent = agent end |
Instance Method Details
#find(id) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/itch/game_map.rb', line 48 def find(id) id = id.to_s map.values.find do |value| value[:id] == id end end |
#find!(id) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/itch/game_map.rb', line 41 def find!(id) result = find(id) raise Error, "Cannot find game with id #{id}" unless result result end |
#find_by_name(name) ⇒ Object
30 31 32 |
# File 'lib/itch/game_map.rb', line 30 def find_by_name(name) map[name] end |
#find_by_name!(name) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/itch/game_map.rb', line 34 def find_by_name!(name) result = find_by_name(name) raise Error, "Cannot find game with name #{name}" unless result result end |