Sha256: 47bd57be85166980d5fcff406c37d504d16baff3f3431803c576de938e326d80
Contents?: true
Size: 651 Bytes
Versions: 3
Compression:
Stored size: 651 Bytes
Contents
require 'erb' require 'json' class Fdoc::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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
fdoc-0.3.3 | lib/fdoc/presenters/json_presenter.rb |
fdoc-0.3.2 | lib/fdoc/presenters/json_presenter.rb |
fdoc-0.3.1 | lib/fdoc/presenters/json_presenter.rb |