Sha256: 769c9000385ae52d2c9b23789a00e2c6e726b33344b77fd660fecf8c28af8113
Contents?: true
Size: 1.09 KB
Versions: 25
Compression:
Stored size: 1.09 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, { compression: false }) json end # @param output [Vedeu::Models::Page] # @return [String] def render(output) json = parse(output) super(json, { compression: false }) 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
25 entries across 25 versions & 1 rubygems