Class: ChupaText::Formatters::JSON
- Inherits:
-
Object
- Object
- ChupaText::Formatters::JSON
- Defined in:
- lib/chupa-text/formatters/json.rb
Instance Method Summary collapse
- #format_extracted(data) ⇒ Object
- #format_finish(data) ⇒ Object
- #format_start(data) ⇒ Object
-
#initialize(output) ⇒ JSON
constructor
A new instance of JSON.
Constructor Details
#initialize(output) ⇒ JSON
Returns a new instance of JSON.
22 23 24 25 |
# File 'lib/chupa-text/formatters/json.rb', line 22 def initialize(output) @output = output @texts = [] end |
Instance Method Details
#format_extracted(data) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/chupa-text/formatters/json.rb', line 30 def format_extracted(data) text = {} format_headers(data, text) text["body"] = data.body @texts << text end |
#format_finish(data) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/chupa-text/formatters/json.rb', line 37 def format_finish(data) formatted = {} format_headers(data, formatted) formatted["texts"] = @texts @output << ::JSON.pretty_generate(formatted) @output << "\n" end |
#format_start(data) ⇒ Object
27 28 |
# File 'lib/chupa-text/formatters/json.rb', line 27 def format_start(data) end |