Class: Aranha::Parsers::SourceAddress::HttpGet
- Inherits:
-
Object
- Object
- Aranha::Parsers::SourceAddress::HttpGet
- Defined in:
- lib/aranha/parsers/source_address/http_get.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #content ⇒ Object
- #final_url ⇒ Object
-
#initialize(source) ⇒ HttpGet
constructor
A new instance of HttpGet.
- #serialize ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(source) ⇒ HttpGet
Returns a new instance of HttpGet.
24 25 26 |
# File 'lib/aranha/parsers/source_address/http_get.rb', line 24 def initialize(source) @source = source.to_s end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
22 23 24 |
# File 'lib/aranha/parsers/source_address/http_get.rb', line 22 def source @source end |
Class Method Details
.location_uri(source_uri, location) ⇒ Object
13 14 15 |
# File 'lib/aranha/parsers/source_address/http_get.rb', line 13 def location_uri(source_uri, location) ::Addressable::URI.join(source_uri, location).to_s end |
.valid_source?(source) ⇒ Boolean
17 18 19 |
# File 'lib/aranha/parsers/source_address/http_get.rb', line 17 def valid_source?(source) source.to_s =~ %r{\Ahttps?://} end |
Instance Method Details
#==(other) ⇒ Object
28 29 30 |
# File 'lib/aranha/parsers/source_address/http_get.rb', line 28 def ==(other) self.class == other.class && source == other.source end |
#content ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/aranha/parsers/source_address/http_get.rb', line 41 def content request = ::EacEnvs::Http::Request.new.url(url).retry(true).follow_redirect(true) .header('user-agent', self.class.name) request.response.body_str rescue ::EacEnvs::Http::Error => e raise ::Aranha::Parsers::SourceAddress::FetchContentError, e., request end |
#final_url ⇒ Object
36 37 38 39 |
# File 'lib/aranha/parsers/source_address/http_get.rb', line 36 def final_url content unless @final_url @final_url end |
#serialize ⇒ Object
49 50 51 |
# File 'lib/aranha/parsers/source_address/http_get.rb', line 49 def serialize url end |
#url ⇒ Object
32 33 34 |
# File 'lib/aranha/parsers/source_address/http_get.rb', line 32 def url source end |