Class: GhSearch::Formatters::Json
- Inherits:
-
Base
- Object
- Base
- GhSearch::Formatters::Json
show all
- Defined in:
- lib/gh_search/formatters/json.rb
Instance Attribute Summary
Attributes inherited from Base
#output_file
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #write!
Instance Method Details
#write(match) ⇒ Object
6
7
8
9
10
|
# File 'lib/gh_search/formatters/json.rb', line 6
def write(match)
@data ||= []
@data << match
print_and_flush('.') if output_file
end
|
#write_file! ⇒ Object
12
13
14
15
16
17
18
19
20
|
# File 'lib/gh_search/formatters/json.rb', line 12
def write_file!
if output_file
@file ||= File.open(output_file, "w")
@file.write @data.to_json
@file.close
else
puts @data
end
end
|