Class: WebLoader::Response
- Inherits:
-
Object
- Object
- WebLoader::Response
- Includes:
- Utils
- Defined in:
- lib/web_loader/response.rb
Constant Summary
Constants included from Utils
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(status:, headers: {}, body: nil) ⇒ Response
constructor
A new instance of Response.
- #ok? ⇒ Boolean
- #rate_limited? ⇒ Boolean
- #redirect? ⇒ Boolean
Methods included from Utils
detect_charset, to_redirect_url, toutf8, toutf8_charset
Constructor Details
#initialize(status:, headers: {}, body: nil) ⇒ Response
Returns a new instance of Response.
10 11 12 13 14 |
# File 'lib/web_loader/response.rb', line 10 def initialize(status:, headers: {}, body: nil) @status = status.to_i @headers = headers || {} @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
16 17 18 |
# File 'lib/web_loader/response.rb', line 16 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
16 17 18 |
# File 'lib/web_loader/response.rb', line 16 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
16 17 18 |
# File 'lib/web_loader/response.rb', line 16 def status @status end |
Class Method Details
.from_selenium(driver, original_url) ⇒ Object
6 7 8 |
# File 'lib/web_loader/response.rb', line 6 def self.from_selenium(driver, original_url) end |
Instance Method Details
#ok? ⇒ Boolean
18 |
# File 'lib/web_loader/response.rb', line 18 def ok?; (200..299).include?(@status); end |
#rate_limited? ⇒ Boolean
20 |
# File 'lib/web_loader/response.rb', line 20 def rate_limited?; @status == 429; end |
#redirect? ⇒ Boolean
19 |
# File 'lib/web_loader/response.rb', line 19 def redirect?; (300..399).include?(@status); end |