Class: Bookbinder::Spider::Stabilimentum

Inherits:
Object
  • Object
show all
Defined in:
lib/bookbinder/stabilimentum.rb

Overview

Decorates a piece of the web.

Defined Under Namespace

Classes: FudgedUri

Instance Method Summary collapse

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

Returns:

  • (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

Returns:

  • (Boolean)


14
15
16
# File 'lib/bookbinder/stabilimentum.rb', line 14

def not_found?
  @page.not_found?
end

#refererObject



10
11
12
# File 'lib/bookbinder/stabilimentum.rb', line 10

def referer
  @page.referer
end

#urlObject



18
19
20
# File 'lib/bookbinder/stabilimentum.rb', line 18

def url
  @page.url
end