Sha256: eb9f3e7c7a1f2e0f0205c64796c8ea924a48bd011c0a3db3e07801cfd53f3db7
Contents?: true
Size: 1.05 KB
Versions: 23
Compression:
Stored size: 1.05 KB
Contents
module Vedeu module Renderers # Renders a {Vedeu::Terminal::Buffer} 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 # Render a cleared output. # # @return [String] def clear json = parse({}) super(json) json end # @param output [Vedeu::Models::Page] # @return [String] def render(output) json = parse(output) super(json) json end private # @param output [Vedeu::Models::Page] # @return [String] def parse(output) ::JSON.pretty_generate(as_hash(output)) end # @param output [Vedeu::Models::Page] # @return [Array] def as_hash(output) return output if output.is_a?(Hash) output.content.map(&:to_hash) end end # JSON end # Renderers end # Vedeu
Version data entries
23 entries across 23 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.6.15 | lib/vedeu/output/renderers/json.rb |
vedeu-0.6.14 | lib/vedeu/output/renderers/json.rb |
vedeu-0.6.13 | lib/vedeu/output/renderers/json.rb |