Sha256: c3da86c4eb60fce5b30b30182c1ecdc67d55c2ba3fccb3c655046443da0b0cd9

Contents?: true

Size: 491 Bytes

Versions: 12

Compression:

Stored size: 491 Bytes

Contents

require 'erb'
require 'json'
class Lurker::JsonPresenter
  attr_reader :json

  def initialize(json)
    @json = json
  end

  def to_html
    if json.is_a? String
      '<tt>&quot;%s&quot;</tt>' % json.gsub(/\"/, 'quot;')
    elsif json.is_a?(Numeric) ||
          json.is_a?(TrueClass) ||
          json.is_a?(FalseClass)
      '<tt>%s</tt>' % json
    elsif json.is_a?(Hash) ||
          json.is_a?(Array)
      '<pre><code>%s</code></pre>' % JSON.pretty_generate(json)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
lurker-1.0.0 lib/lurker/presenters/json_presenter.rb
lurker-0.6.12 lib/lurker/presenters/json_presenter.rb
lurker-0.6.11 lib/lurker/presenters/json_presenter.rb
lurker-0.6.10 lib/lurker/presenters/json_presenter.rb
lurker-0.6.9 lib/lurker/presenters/json_presenter.rb
lurker-0.6.8 lib/lurker/presenters/json_presenter.rb
lurker-0.6.7 lib/lurker/presenters/json_presenter.rb
lurker-0.6.6 lib/lurker/presenters/json_presenter.rb
lurker-0.6.5 lib/lurker/presenters/json_presenter.rb
lurker-0.6.4 lib/lurker/presenters/json_presenter.rb
lurker-0.6.3 lib/lurker/presenters/json_presenter.rb
lurker-0.6.2 lib/lurker/presenters/json_presenter.rb