Class: Anaximander::Discovery::Links
- Inherits:
-
Object
- Object
- Anaximander::Discovery::Links
- Extended by:
- Forwardable
- Includes:
- Comparable, Enumerable
- Defined in:
- lib/anaximander/discovery/links.rb
Overview
Collection of internal links on the given page.
Relative Paths
‘Anaximander::Discovery::Links` converts all relative paths into absolute paths using the base URL of the page being crawled.
# http://example.com
<a href="/contact">Contact</a>
Anaximander::Discovery::Links.new(Nokogiri::HTML(open("http://example.com")))
# => ["http://example.com/contact"]
Exclusions
- External links (ones outside the domain of the page
- Hash links (Javascript style links with href of "#")
Example
page = Nokogiri::HTML(open("http://example.com"))
Anaximander::Discovery::Links.new(page)
# => ["http://www.iana.org/domains/example"]
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(page, url) ⇒ Links
constructor
Parameters.
Constructor Details
Instance Method Details
#<=>(other) ⇒ Object
49 50 51 |
# File 'lib/anaximander/discovery/links.rb', line 49 def <=>(other) to_a <=> other.to_a end |
#each(&block) ⇒ Object
45 46 47 |
# File 'lib/anaximander/discovery/links.rb', line 45 def each(&block) links.each(&block) end |