Sha256: c402c2d9fe1b4a36dfe14fd3388fba15dd36090f5d9da42404f287bfdcefe38a
Contents?: true
Size: 653 Bytes
Versions: 4
Compression:
Stored size: 653 Bytes
Contents
require 'erb' require 'json' class Lurker::JsonPresenter attr_reader :json def initialize(json) @json = json end def to_html if json.kind_of? String '<tt>"%s"</tt>' % json.gsub(/\"/, 'quot;') elsif json.kind_of?(Numeric) || json.kind_of?(TrueClass) || json.kind_of?(FalseClass) '<tt>%s</tt>' % json elsif json.kind_of?(Hash) || json.kind_of?(Array) '<pre><code>%s</code></pre>' % JSON.pretty_generate(json) end end def to_markdown if json.kind_of?(Hash) || json.kind_of?(Array) JSON.pretty_generate(json) else json end end end
Version data entries
4 entries across 4 versions & 1 rubygems