Class: Hearthstone::Log::GameLogger

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(delegate, debug: false) ⇒ GameLogger

Returns a new instance of GameLogger.



10
11
12
13
14
15
16
# File 'lib/hearthstone/log/game_logger.rb', line 10

def initialize(delegate, debug: false)
  @delegate = delegate
  @parser = Parser.new
  @game = Game.new(nil)
  @debug = debug
  @mode = nil
end

Instance Attribute Details

#debugObject (readonly)

Returns the value of attribute debug.



7
8
9
# File 'lib/hearthstone/log/game_logger.rb', line 7

def debug
  @debug
end

#delegateObject

Returns the value of attribute delegate.



8
9
10
# File 'lib/hearthstone/log/game_logger.rb', line 8

def delegate
  @delegate
end

#gameObject

Returns the value of attribute game.



8
9
10
# File 'lib/hearthstone/log/game_logger.rb', line 8

def game
  @game
end

#modeObject

Returns the value of attribute mode.



8
9
10
# File 'lib/hearthstone/log/game_logger.rb', line 8

def mode
  @mode
end

#parserObject (readonly)

Returns the value of attribute parser.



7
8
9
# File 'lib/hearthstone/log/game_logger.rb', line 7

def parser
  @parser
end

Instance Method Details

#log_file(io) ⇒ Object



18
19
20
21
22
# File 'lib/hearthstone/log/game_logger.rb', line 18

def log_file(io)
  io.each_line do |line|
    log_line(line)
  end
end

#log_line(line) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/hearthstone/log/game_logger.rb', line 24

def log_line(line)
  result = parser.parse_line(line)
  if result
    name = result[0]
    data = result[1]
    log_line = line if self.debug
    process_event(name, data, log_line)
  end
end