Class: Hearthstone::Log::GameTurn

Inherits:
Object
  • Object
show all
Defined in:
lib/hearthstone/log/data/game_turn.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number: nil, player: nil, timestamp: nil) ⇒ GameTurn

Returns a new instance of GameTurn.



7
8
9
10
11
12
# File 'lib/hearthstone/log/data/game_turn.rb', line 7

def initialize(number: nil, player: nil, timestamp: nil)
  @events = []
  @number = number
  @player = player
  @timestamp = timestamp        
end

Instance Attribute Details

#eventsObject (readonly)

Returns the value of attribute events.



5
6
7
# File 'lib/hearthstone/log/data/game_turn.rb', line 5

def events
  @events
end

#numberObject

Returns the value of attribute number.



4
5
6
# File 'lib/hearthstone/log/data/game_turn.rb', line 4

def number
  @number
end

#playerObject

Returns the value of attribute player.



4
5
6
# File 'lib/hearthstone/log/data/game_turn.rb', line 4

def player
  @player
end

#timestampObject

Returns the value of attribute timestamp.



4
5
6
# File 'lib/hearthstone/log/data/game_turn.rb', line 4

def timestamp
  @timestamp
end

Instance Method Details

#add_event(event, data, line = nil) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/hearthstone/log/data/game_turn.rb', line 14

def add_event(event, data, line=nil)
  if line
    @events.push([event, data, line])
  else
    @events.push([event, data])
  end
end

#to_hashObject



22
23
24
25
26
27
28
29
# File 'lib/hearthstone/log/data/game_turn.rb', line 22

def to_hash
  {
    number: number,
    player: player,
    timestamp: timestamp,
    events: events
  }
end