Class: Fluent::Compat::ExecUtil::TSVParser

Inherits:
Parser
  • Object
show all
Defined in:
lib/fluent/compat/exec_util.rb

Instance Method Summary collapse

Constructor Details

#initialize(keys, on_message) ⇒ TSVParser

Returns a new instance of TSVParser.



59
60
61
62
# File 'lib/fluent/compat/exec_util.rb', line 59

def initialize(keys, on_message)
  @keys = keys
  super(on_message)
end

Instance Method Details

#call(io) ⇒ Object



64
65
66
# File 'lib/fluent/compat/exec_util.rb', line 64

def call(io)
  io.each_line(&method(:each_line))
end

#each_line(line) ⇒ Object



68
69
70
71
72
73
74
75
# File 'lib/fluent/compat/exec_util.rb', line 68

def each_line(line)
  line.chomp!
  vals = line.split("\t")

  record = Hash[@keys.zip(vals)]

  @on_message.call(record)
end