Class: Glib::JsonCrawler::Http
- Inherits:
-
Object
- Object
- Glib::JsonCrawler::Http
- Defined in:
- lib/glib/json_crawler/http.rb
Defined Under Namespace
Classes: Response
Constant Summary collapse
- URI_REGEXP =
/\A#{URI.regexp}\z/- VALID_RESPONSE_CODES =
[ (200..299).to_a, 401, ## UNAUTHORIZED Should be used for not-logged-in 403, ## FORBIDDEN Should be used for logged-in but not allowed to access ].flatten
Instance Attribute Summary collapse
-
#history ⇒ Object
Returns the value of attribute history.
-
#response_times ⇒ Object
Returns the value of attribute response_times.
-
#router ⇒ Object
Returns the value of attribute router.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #delete(url, action, params = {}) ⇒ Object
- #get(url, action, params = {}) ⇒ Object
-
#initialize(context, user, router, inspect_result: true) ⇒ Http
constructor
A new instance of Http.
- #patch(url, action, params) ⇒ Object
- #post(url, action, params) ⇒ Object
- #put(url, action, params) ⇒ Object
Constructor Details
#initialize(context, user, router, inspect_result: true) ⇒ Http
Returns a new instance of Http.
14 15 16 17 18 19 20 21 22 |
# File 'lib/glib/json_crawler/http.rb', line 14 def initialize(context, user, router, inspect_result: true) @context = context @history = [] @content_history = [] @response_times = [] @user = user @router = router @inspect_result = inspect_result end |
Instance Attribute Details
#history ⇒ Object
Returns the value of attribute history.
4 5 6 |
# File 'lib/glib/json_crawler/http.rb', line 4 def history @history end |
#response_times ⇒ Object
Returns the value of attribute response_times.
4 5 6 |
# File 'lib/glib/json_crawler/http.rb', line 4 def response_times @response_times end |
#router ⇒ Object
Returns the value of attribute router.
4 5 6 |
# File 'lib/glib/json_crawler/http.rb', line 4 def router @router end |
#user ⇒ Object
Returns the value of attribute user.
4 5 6 |
# File 'lib/glib/json_crawler/http.rb', line 4 def user @user end |
Instance Method Details
#delete(url, action, params = {}) ⇒ Object
40 41 42 |
# File 'lib/glib/json_crawler/http.rb', line 40 def delete(url, action, params = {}) fetch(:delete, url, action, {}, @inspect_result) end |
#get(url, action, params = {}) ⇒ Object
24 25 26 |
# File 'lib/glib/json_crawler/http.rb', line 24 def get(url, action, params = {}) fetch(:get, url, action, params, @inspect_result) end |
#patch(url, action, params) ⇒ Object
32 33 34 |
# File 'lib/glib/json_crawler/http.rb', line 32 def patch(url, action, params) fetch(:patch, url, action, params, @inspect_result) end |
#post(url, action, params) ⇒ Object
28 29 30 |
# File 'lib/glib/json_crawler/http.rb', line 28 def post(url, action, params) fetch(:post, url, action, params, @inspect_result) end |
#put(url, action, params) ⇒ Object
36 37 38 |
# File 'lib/glib/json_crawler/http.rb', line 36 def put(url, action, params) fetch(:put, url, action, params, @inspect_result) end |