lib/bad_browser/user_agent.rb
def to_json(result = nil)
    browser_str = @browser.nil? ? 'null' : %Q("#{browser}")

    if failed?
      %Q({"failed":true,"browser":#{browser_str},"version":null,"string":"#{string}"})
    elsif !result.nil?
      %Q({"result":#{result},"browser":#{browser_str},"version":"#{version.string}","string":"#{string}"})
    else
      # we must be called by other code or tests (thus don't include failed or result flag)
      %Q({"browser":#{browser},"version":"#{@version.string}","string":"#{@string}"})
    end
  end
# Convert object to a JSON representation for public consumption. Can easily use a JSON gem
# but it's just faster to build it by hand
Convert object to a JSON representation for public consumption. Can easily use a JSON gem
but it's just faster to build it by hand
Convert object to a JSON representation for public consumption . Can easily use a JSON gem but it ' s just faster to build it by hand
def to_json(result = nil)
    browser_str = @browser.nil? ? 'null' : %Q("#{browser}")
    if failed?
      %Q({"failed":true,"browser":#{browser_str},"version":null,"string":"#{string}"})
    elsif !result.nil?
      %Q({"result":#{result},"browser":#{browser_str},"version":"#{version.string}","string":"#{string}"})
    else
      %Q({"browser":#{browser},"version":"#{@version.string}","string":"#{@string}"})
    end
  end
def to_json ( result = nil ) browser_str = @browser . nil? ? 'null' : %Q("#{browser}") if failed? %Q({"failed":true,"browser":#{browser_str},"version":null,"string":"#{string}"}) elsif ! result . nil? %Q({"result":#{result},"browser":#{browser_str},"version":"#{version.string}","string":"#{string}"}) else %Q({"browser":#{browser},"version":"#{@version.string}","string":"#{@string}"}) end end
Convert object to a JSON representation for public consumption.
Convert object to a JSON representation for public consumption .
# we must be called by other code or tests (thus don't include failed or result flag)
result