Sha256: 451e7ab7ef2b4f72d8b1042d0ceff214c8cd6a4c9da11752d74fab3ba7e84759
Contents?: true
Size: 1.13 KB
Versions: 3
Compression:
Stored size: 1.13 KB
Contents
class URL # Handlers for making requests for the URL. To create your own you need to follow the following conventions: # 1. You must define the get, post, and delete instance methods # 2. These methods should return a {Response} object # # To create a {Response} object: # hsh = { # :code => resp.code, # :time => resp.time, # :body => resp.body, # :response => resp, # :url => url.to_s # } # Response.new(hsh) class RequestHandler attr_reader :url def initialize(url) @url = url end def get(args={}) raise Exception, "You need to implement #{self.class}#get" end def post(args={}) raise Exception, "You need to implement #{self.class}#post" end def delete(args={}) raise Exception, "You need to implement #{self.class}#delete" end end class JSONHandler attr_reader :str def initialize(str) @str = str end def parse raise Exception, "You need to implement #{self.class}#parse" end end end Dir[File.join(File.dirname(__FILE__),'handlers','*.rb')].each {|f| require f}
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
url-0.2.2 | lib/url/handlers.rb |
url-0.2.1 | lib/url/handlers.rb |
url-0.2.0 | lib/url/handlers.rb |