Class: Vedeu::Renderers::JSON
- Inherits:
-
Object
- Object
- Vedeu::Renderers::JSON
- Defined in:
- lib/vedeu/output/renderers/json.rb
Overview
Renders a VirtualBuffer or Output as JSON.
Instance Attribute Summary collapse
- #output ⇒ Array<Array<Vedeu::Char>> readonly protected
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(output) ⇒ Vedeu::Renderers::JSON
constructor
Returns a new instance of Vedeu::Renderers::JSON.
- #render ⇒ String
Constructor Details
#initialize(output) ⇒ Vedeu::Renderers::JSON
Returns a new instance of Vedeu::Renderers::JSON.
25 26 27 |
# File 'lib/vedeu/output/renderers/json.rb', line 25 def initialize(output) @output = output end |
Instance Attribute Details
#output ⇒ Array<Array<Vedeu::Char>> (readonly, protected)
49 50 51 |
# File 'lib/vedeu/output/renderers/json.rb', line 49 def output @output end |
Class Method Details
.render(output) ⇒ String
10 11 12 |
# File 'lib/vedeu/output/renderers/json.rb', line 10 def self.render(output) new(output).render end |
Instance Method Details
#render ⇒ String
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/vedeu/output/renderers/json.rb', line 30 def render return '' if output.nil? || output.empty? out = '' Array(output).each do |line| out << '' line.each do |char| out << char.to_json out << "\n" end out << "\n" end out end |