class Cheatsheet::Client
Constants
- SOURCE
Public Class Methods
fetch(*args)
click to toggle source
# File lib/cheatsheet/client.rb, line 6 def self.fetch(*args) key = args[0].first uri = URI(SOURCE + key + ".md") begin puts self.fetch_raw(uri) rescue CheatSheetClientException => e puts e.message end end
fetch_raw(uri)
click to toggle source
# File lib/cheatsheet/client.rb, line 17 def self.fetch_raw(uri) response = Net::HTTP.get_response(uri) case response when Net::HTTPSuccess then Net::HTTP.get(uri) when Net::HTTPNotFound then raise CheatSheetClientException.new "We don't have that cheatsheet yet. Feel free to contribute here: https://github.com/rstacruz/cheatsheets" else response.value end end