Sha256: 9f5e3f99fbfa534431f0ac1267e35cdc222b3dcc0ec1320b29f2e649590e0a0a
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
require 'httparty' module XkcdGuru class Client attr_accessor :url # XkcdGuru::Client.new('http://localhost:3000') # XkcdGuru::Client.new('http://xkcd-unofficial-api.herokuapp.com/xkcd') def initialize(url) @url = url end # response = HTTParty.get('http://xkcd-unofficial-api.herokuapp.com/xkcd?year=2007') #this gets comics 1-60 # all_comics = {}; # for num in 0..60 # all_comics[num] = HTTParty.get("http://xkcd.com/#{num}/info.0.json") # end def comic_by_date(year, month = nil, day = nil) if day day_text = "&day=#{day}" end if month month_text = "&month=#{month}" #{month_text}#{day_text}") end def comic_by_month(month, day = nil) return HTTParty.get("#{@url}?month=#{month}") end def comic_by_day(day) return HTTParty.get("#{@url}?day=#{day}") end def comic_by_num(num) return HTTParty.get("#{@url}?num=#{num}") end def comic_by_title(safe_title) return HTTParty.get("#{@url}?safe_title=#{safe_title}") end def comic_by_alt(alt) return HTTParty.get("#{@url}?alt=#{alt}") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
xkcd-gem-0.0.0 | lib/xkcd-gem.rb |