Sha256: e68a79cb94d85e8751dc0d300ed0f5ba59ea893afcdb9cb1ed61bb6396f7533e
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
module Vedeu module Renderers # Renders a {Vedeu::Buffers::VirtualBuffer} or # {Vedeu::Output::Output} as JSON. # class JSON < Vedeu::Renderers::File # Returns a new instance of Vedeu::Renderers::JSON. # # @param options [Hash] # @return [Vedeu::Renderers::JSON] def initialize(options = {}) @options = options || {} end # @param output [Array<Array<Vedeu::Views::Char>>] # @return [String] def render(output) super(parsed(output)) end private # @param output [Array<Array<Vedeu::Views::Char>>] # @return [String] def parsed(output) return '' if output.nil? || output.empty? ::JSON.pretty_generate(as_hash(output)) end # @param output [Array<Array<Vedeu::Views::Char>>] # @return [Array] def as_hash(output) sorted(output).map(&:to_hash) end # @param output [Array<Array<Vedeu::Views::Char>>] # @return [Array] def sorted(output) Array(output).flatten.sort_by(&:position) end end # JSON end # Renderers end # Vedeu
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.6.9 | lib/vedeu/output/renderers/json.rb |