Class: Battlesnake::Game

Inherits:
Base
  • Object
show all
Defined in:
lib/battlesnake/game.rb

Overview

Represents a Battlesnake game.

Instance Attribute Summary collapse

Instance Method Summary collapse

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_jsonHash (readonly)



8
9
10
# File 'lib/battlesnake/game.rb', line 8

def as_json
  @as_json
end

#idString (readonly)



11
12
13
# File 'lib/battlesnake/game.rb', line 11

def id
  @id
end

#mapString (readonly)



17
18
19
# File 'lib/battlesnake/game.rb', line 17

def map
  @map
end

#rulesetHash (readonly)



14
15
16
# File 'lib/battlesnake/game.rb', line 14

def ruleset
  @ruleset
end

#sourceString (readonly)



23
24
25
# File 'lib/battlesnake/game.rb', line 23

def source
  @source
end

#timeoutInteger (readonly)



20
21
22
# File 'lib/battlesnake/game.rb', line 20

def timeout
  @timeout
end