Class: E621::API
- Inherits:
-
Object
- Object
- E621::API
- Defined in:
- lib/api.rb
Instance Method Summary collapse
-
#initialize(user = nil, pass = nil) ⇒ API
constructor
A new instance of API.
-
#method_missing(method, *args) ⇒ Object
Send commands to API and parse all answers, even errors.
-
#post_list(*args) ⇒ Object
A wrapper function to fit into the general theme better.
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
Send commands to API and parse all answers, even errors. Also make it work with POST and GET requests.
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/api.rb', line 34 def method_missing(method,*args) request = request2body(args.first) method = method.to_s.split("_") m = case method[0] when "post" then case method[1] when "show" then :get else :post end else :post end @http.__send__(m,"/#{method.join("/")}.json",request) end |
Instance Method Details
#post_list(*args) ⇒ Object
A wrapper function to fit into the general theme better.
29 30 31 |
# File 'lib/api.rb', line 29 def post_list(*args) post_index(*args) end |