class Fdoc::JsonPresenter

Attributes

json[R]

Public Class Methods

new(json) click to toggle source
# File lib/fdoc/presenters/json_presenter.rb, line 6
def initialize(json)
  @json = json
end

Public Instance Methods

to_html() click to toggle source
# File lib/fdoc/presenters/json_presenter.rb, line 10
def to_html
  if json.kind_of? String
    '<tt>&quot;%s&quot;</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
to_markdown() click to toggle source
# File lib/fdoc/presenters/json_presenter.rb, line 23
def to_markdown
  if json.kind_of?(Hash) ||
     json.kind_of?(Array)
    JSON.pretty_generate(json)
  else
    json
  end
end