Class: QuakeLogParser::KafkaTopicReader

Inherits:
Object
  • Object
show all
Defined in:
lib/quake-log-parser/kafka_topic_reader.rb

Instance Method Summary collapse

Constructor Details

#initialize(messages) ⇒ KafkaTopicReader

Returns a new instance of KafkaTopicReader.



3
4
5
6
# File 'lib/quake-log-parser/kafka_topic_reader.rb', line 3

def initialize(messages)
  @messages = messages
  @line_handler = QuakeLogParser::LineHandler.new
end

Instance Method Details

#readObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/quake-log-parser/kafka_topic_reader.rb', line 8

def read
  @messages.each do |message|
    if message.payload['lines']
      message.payload['lines'].each do |line|
        case line
        when QuakeLogParser::Patterns.new_game
          @line_handler.handle_new_game(line)
        when QuakeLogParser::Patterns.new_player
          @line_handler.handle_new_player(line)
        when QuakeLogParser::Patterns.new_kill
          @line_handler.handle_new_kill(line)
        end
      end
    end
  end
end

#resultsObject



25
26
27
# File 'lib/quake-log-parser/kafka_topic_reader.rb', line 25

def results
  @line_handler.results
end