Class: Vedeu::Renderers::JSON
- Defined in:
- lib/vedeu/output/renderers/json.rb
Overview
Renders a Terminal::Buffer as JSON.
Instance Attribute Summary collapse
-
#options ⇒ Hash<Symbol => void>
included
from Options
private
Combines the options provided at instantiation with the default values.
Instance Method Summary collapse
- #as_hash(output) ⇒ Array private
-
#clear ⇒ String
Render a cleared output.
-
#initialize(options = {}) ⇒ Vedeu::Renderers::JSON
constructor
Returns a new instance of Vedeu::Renderers::JSON.
- #parse(output) ⇒ String private
- #render(output) ⇒ String
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 Attribute Details
#options ⇒ Hash<Symbol => void> (private) Originally defined in module Options
Combines the options provided at instantiation with the default values.
Instance Method Details
#as_hash(output) ⇒ Array (private)
48 49 50 51 52 |
# File 'lib/vedeu/output/renderers/json.rb', line 48 def as_hash(output) return output if output.is_a?(Hash) output.content.map(&:to_hash) end |
#clear ⇒ String
Render a cleared output.
20 21 22 23 24 25 26 |
# File 'lib/vedeu/output/renderers/json.rb', line 20 def clear json = parse({}) super(json) json end |
#parse(output) ⇒ String (private)
42 43 44 |
# File 'lib/vedeu/output/renderers/json.rb', line 42 def parse(output) ::JSON.pretty_generate(as_hash(output)) end |
#render(output) ⇒ String
30 31 32 33 34 35 36 |
# File 'lib/vedeu/output/renderers/json.rb', line 30 def render(output) json = parse(output) super(json) json end |