module Curldown

Public Class Methods

render(user: false, repo: false, url: false, github: false, bitbucket: false) click to toggle source
# File lib/curldown.rb, line 7
def self.render(user: false, repo: false, url: false, github: false, bitbucket: false)
  instance = Render.new(user: user, repo: repo, url: url, github: github, bitbucket: bitbucket)
  instance.render
  instance.highlight!
  instance
end

Public Instance Methods

get(url, json: true) click to toggle source
# File lib/curldown.rb, line 13
def get(url, json: true)
  http = Curl::Easy.new(url)
  http.perform
  if http.status[0] == "2"
    if json
      response = JSON.parse(http.body_str)
    else
      response = http.body_str
    end
  else
    raise StandardError.new("get method returned #{http.status} code when calling #{http.url}")
  end
  response
end