Sha256: 5da9423fc2601a8a6e864e05f1cb566463a64d707612bef1e458284790185897

Contents?: true

Size: 524 Bytes

Versions: 4

Compression:

Stored size: 524 Bytes

Contents

module Vedeu

  module Renderers

    # Renders a {Vedeu::VirtualBuffer} or {Vedeu::Output} as JSON.
    #
    # @api private
    class JSON < Vedeu::Renderers::File

      private

      # @return [String]
      def parsed
        return '' if output.nil? || output.empty?

        ::JSON.pretty_generate(sorted)
      end

      # @return [Array]
      def sorted
        Array(output).flatten.sort { |a, b| a.position <=> b.position }.map { |char| char.to_hash }
      end

    end # JSON

  end # Renderers

end # Vedeu

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vedeu-0.4.43 lib/vedeu/output/renderers/json.rb
vedeu-0.4.42 lib/vedeu/output/renderers/json.rb
vedeu-0.4.41 lib/vedeu/output/renderers/json.rb
vedeu-0.4.40 lib/vedeu/output/renderers/json.rb