Class: Crabbs::Page
- Inherits:
-
Object
- Object
- Crabbs::Page
- Defined in:
- lib/crabbs/page.rb
Instance Method Summary collapse
-
#initialize(html, url) ⇒ Page
constructor
A new instance of Page.
- #links ⇒ Object
Constructor Details
#initialize(html, url) ⇒ Page
Returns a new instance of Page.
6 7 8 9 |
# File 'lib/crabbs/page.rb', line 6 def initialize(html, url) @html = Nokogiri::HTML(html) @url = url end |
Instance Method Details
#links ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/crabbs/page.rb', line 11 def links links = @html.css('a[href]').map { |a| Crabbs::Link.new a['href'] } links .select { |link| link.same_host_as? @url } .select(&:has_valid_fragment?) .select(&:has_html_extension?) .map { |link| link.join @url } .uniq end |