Class: Hearthstone::Log::GameLogger
- Inherits:
-
Object
- Object
- Hearthstone::Log::GameLogger
- Defined in:
- lib/hearthstone/log/game_logger.rb
Instance Attribute Summary collapse
-
#debug ⇒ Object
readonly
Returns the value of attribute debug.
-
#delegate ⇒ Object
Returns the value of attribute delegate.
-
#game ⇒ Object
Returns the value of attribute game.
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Instance Method Summary collapse
-
#initialize(delegate, debug: false) ⇒ GameLogger
constructor
A new instance of GameLogger.
- #log_file(io) ⇒ Object
- #log_line(line) ⇒ Object
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
#debug ⇒ Object (readonly)
Returns the value of attribute debug.
7 8 9 |
# File 'lib/hearthstone/log/game_logger.rb', line 7 def debug @debug end |
#delegate ⇒ Object
Returns the value of attribute delegate.
8 9 10 |
# File 'lib/hearthstone/log/game_logger.rb', line 8 def delegate @delegate end |
#game ⇒ Object
Returns the value of attribute game.
8 9 10 |
# File 'lib/hearthstone/log/game_logger.rb', line 8 def game @game end |
#mode ⇒ Object
Returns the value of attribute mode.
8 9 10 |
# File 'lib/hearthstone/log/game_logger.rb', line 8 def mode @mode end |
#parser ⇒ Object (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 |