Class: Magellan::Result
- Inherits:
-
Object
- Object
- Magellan::Result
- Defined in:
- lib/magellan/result.rb
Overview
The resulting data from crawling a url
Instance Attribute Summary collapse
-
#destination_url ⇒ Object
readonly
The destination URL after following redirects.
-
#linked_resources ⇒ Object
readonly
Relative linked resources (based off of the kinds of links you are looking for).
-
#status_code ⇒ Object
readonly
The http status code returned by the request for the specified url.
-
#url ⇒ Object
readonly
The original URL requested.
Instance Method Summary collapse
-
#absolute_linked_resources ⇒ Object
Absolute links to resources.
-
#html_content? ⇒ Boolean
Was the document text/html.
-
#initialize(status_code, url, destination_url, linked_resources, content_type) ⇒ Result
constructor
create a new result, with the status code, url, destination url, linked resources and content type, see attr_readers for more information about these fields.
Constructor Details
#initialize(status_code, url, destination_url, linked_resources, content_type) ⇒ Result
create a new result, with the status code, url, destination url, linked resources and content type, see attr_readers for more information about these fields
14 15 16 17 18 19 20 |
# File 'lib/magellan/result.rb', line 14 def initialize(status_code,url,destination_url,linked_resources,content_type) # :nodoc: @status_code = status_code @url = url @destination_url = destination_url @linked_resources = linked_resources @content_type = content_type end |
Instance Attribute Details
#destination_url ⇒ Object (readonly)
The destination URL after following redirects
9 10 11 |
# File 'lib/magellan/result.rb', line 9 def destination_url @destination_url end |
#linked_resources ⇒ Object (readonly)
Relative linked resources (based off of the kinds of links you are looking for)
11 12 13 |
# File 'lib/magellan/result.rb', line 11 def linked_resources @linked_resources end |
#status_code ⇒ Object (readonly)
The http status code returned by the request for the specified url
5 6 7 |
# File 'lib/magellan/result.rb', line 5 def status_code @status_code end |
#url ⇒ Object (readonly)
The original URL requested
7 8 9 |
# File 'lib/magellan/result.rb', line 7 def url @url end |
Instance Method Details
#absolute_linked_resources ⇒ Object
Absolute links to resources
23 24 25 |
# File 'lib/magellan/result.rb', line 23 def absolute_linked_resources # :nodoc: absolute_links = linked_resources.map { |linked_resource| linked_resource.to_s.to_absolute_url(destination_url) }.compact end |
#html_content? ⇒ Boolean
Was the document text/html
28 29 30 |
# File 'lib/magellan/result.rb', line 28 def html_content? @content_type.starts_with?("text/html") end |