Class: Bookbinder::Spider::Stabilimentum
- Inherits:
-
Object
- Object
- Bookbinder::Spider::Stabilimentum
- Defined in:
- lib/bookbinder/stabilimentum.rb
Overview
Decorates a piece of the web.
Defined Under Namespace
Classes: FudgedUri
Instance Method Summary collapse
- #fragment_identifiers(targeting_locally: false) ⇒ Object
- #has_target_for?(uri) ⇒ Boolean
-
#initialize(page) ⇒ Stabilimentum
constructor
A new instance of Stabilimentum.
- #not_found? ⇒ Boolean
- #referer ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(page) ⇒ Stabilimentum
Returns a new instance of Stabilimentum.
6 7 8 |
# File 'lib/bookbinder/stabilimentum.rb', line 6 def initialize(page) @page = page end |
Instance Method Details
#fragment_identifiers(targeting_locally: false) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/bookbinder/stabilimentum.rb', line 35 def fragment_identifiers(targeting_locally: false) if targeting_locally fragment_anchor_uris.select { |uri| uri.path.empty? } else fragment_anchor_uris.reject { |uri| uri.path.empty? } end end |
#has_target_for?(uri) ⇒ Boolean
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/bookbinder/stabilimentum.rb', line 22 def has_target_for?(uri) id_selector = uri.fragment name_selector = "[name=#{uri.fragment}]" if @page.doc @page.doc.css("##{id_selector}").any? || @page.doc.css(name_selector).any? else false end rescue Nokogiri::CSS::SyntaxError false end |
#not_found? ⇒ Boolean
14 15 16 |
# File 'lib/bookbinder/stabilimentum.rb', line 14 def not_found? @page.not_found? end |
#referer ⇒ Object
10 11 12 |
# File 'lib/bookbinder/stabilimentum.rb', line 10 def referer @page.referer end |
#url ⇒ Object
18 19 20 |
# File 'lib/bookbinder/stabilimentum.rb', line 18 def url @page.url end |