Class: Vedeu::Renderers::JSON
- Defined in:
- lib/vedeu/output/renderers/json.rb
Overview
Renders a Terminal::Buffer as JSON.
Instance Method Summary collapse
- #as_hash(output) ⇒ Array private
-
#initialize(options = {}) ⇒ Vedeu::Renderers::JSON
constructor
Returns a new instance of Vedeu::Renderers::JSON.
- #parse(output) ⇒ String private
- #render(output) ⇒ String
Methods included from Vedeu::RendererOptions
Constructor Details
#initialize(options = {}) ⇒ Vedeu::Renderers::JSON
Returns a new instance of Vedeu::Renderers::JSON.
13 14 15 |
# File 'lib/vedeu/output/renderers/json.rb', line 13 def initialize( = {}) @options = || {} end |
Instance Method Details
#as_hash(output) ⇒ Array (private)
37 38 39 |
# File 'lib/vedeu/output/renderers/json.rb', line 37 def as_hash(output) output.content.map(&:to_hash) end |
#parse(output) ⇒ String (private)
31 32 33 |
# File 'lib/vedeu/output/renderers/json.rb', line 31 def parse(output) ::JSON.pretty_generate(as_hash(output)) end |
#render(output) ⇒ String
19 20 21 22 23 24 25 |
# File 'lib/vedeu/output/renderers/json.rb', line 19 def render(output) json = parse(output) super(json) json end |