Class: Battlesnake::Game
Overview
Represents a Battlesnake game.
Instance Attribute Summary collapse
-
#as_json ⇒ Hash
readonly
Snake as a data structure usable by other objects.
-
#id ⇒ String
readonly
Unique identifier for this game.
-
#map ⇒ String
readonly
Name of the map used to populate the game board with snakes, food, and hazards.
-
#ruleset ⇒ Hash
readonly
Information about the ruleset being used to run this game.
-
#source ⇒ String
readonly
Source of this game.
-
#timeout ⇒ Integer
readonly
How much time player APIs have to respond to requests for this game.
Instance Method Summary collapse
-
#initialize(json_or_hash) ⇒ Game
constructor
Returns a new instance of Game.
Methods inherited from Base
Constructor Details
#initialize(json_or_hash) ⇒ Game
Returns a new instance of Game.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/battlesnake/game.rb', line 32 def initialize(json_or_hash) data = json_or_hash.is_a?(String) ? JSON.parse(json_or_hash) : json_or_hash @as_json = data @id = data['id'] @ruleset = data['ruleset'] @map = data['map'] @timeout = data['timeout'] @source = data['source'] end |
Instance Attribute Details
#as_json ⇒ Hash (readonly)
Returns snake as a data structure usable by other objects.
8 9 10 |
# File 'lib/battlesnake/game.rb', line 8 def as_json @as_json end |
#id ⇒ String (readonly)
Returns unique identifier for this game.
11 12 13 |
# File 'lib/battlesnake/game.rb', line 11 def id @id end |
#map ⇒ String (readonly)
Returns name of the map used to populate the game board with snakes, food, and hazards.
17 18 19 |
# File 'lib/battlesnake/game.rb', line 17 def map @map end |
#ruleset ⇒ Hash (readonly)
Returns information about the ruleset being used to run this game.
14 15 16 |
# File 'lib/battlesnake/game.rb', line 14 def ruleset @ruleset end |
#source ⇒ String (readonly)
Returns source of this game.
23 24 25 |
# File 'lib/battlesnake/game.rb', line 23 def source @source end |
#timeout ⇒ Integer (readonly)
Returns how much time player APIs have to respond to requests for this game.
20 21 22 |
# File 'lib/battlesnake/game.rb', line 20 def timeout @timeout end |