Sha256: 9aabad52f8656930d9af54fba669d7c5f9c933207ef15f07f7b3e31f2393fbc4
Contents?: true
Size: 509 Bytes
Versions: 6
Compression:
Stored size: 509 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 end
Version data entries
6 entries across 6 versions & 1 rubygems