Class: Logcli::Actions::ExtractJson
- Inherits:
-
Object
- Object
- Logcli::Actions::ExtractJson
- Defined in:
- lib/logcli/actions/extract_json.rb
Instance Attribute Summary collapse
-
#filenames ⇒ Object
readonly
Returns the value of attribute filenames.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(opts) ⇒ ExtractJson
constructor
A new instance of ExtractJson.
Constructor Details
#initialize(opts) ⇒ ExtractJson
Returns a new instance of ExtractJson.
5 6 7 |
# File 'lib/logcli/actions/extract_json.rb', line 5 def initialize opts @filenames = opts.fetch(:filenames) end |
Instance Attribute Details
#filenames ⇒ Object (readonly)
Returns the value of attribute filenames.
4 5 6 |
# File 'lib/logcli/actions/extract_json.rb', line 4 def filenames @filenames end |
Instance Method Details
#call ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/logcli/actions/extract_json.rb', line 9 def call filenames.each do |filename| outfile = generate_out_filename filename File.open outfile, 'w' do |out| File.open(filename).each do |line| out_line = process line out.puts out_line if out_line end end end end |