Class: Zlog::CLI
- Inherits:
-
Object
- Object
- Zlog::CLI
- Defined in:
- lib/zlog/cli.rb
Instance Method Summary collapse
- #convert_line(line, opts = {}) ⇒ Object
- #convert_stdin(opts = {}, &handler) ⇒ Object
-
#initialize(opts = {}) ⇒ CLI
constructor
A new instance of CLI.
Constructor Details
Instance Method Details
#convert_line(line, opts = {}) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/zlog/cli.rb', line 13 def convert_line line, opts = {} e = Zlog::json_2_event(line) if not e.nil? @layout.format(e) end end |
#convert_stdin(opts = {}, &handler) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/zlog/cli.rb', line 20 def convert_stdin opts = {}, &handler # collect all results to an array which will be returned # in case that no block is given for processing res = [] handler = lambda{|line| res.push line} if not block_given? # process each line STDIN.readlines.each do |line| handler.( convert_line line, opts ) end # return the result, in case we have any res end |