Class: LinkToad
- Inherits:
-
Object
- Object
- LinkToad
- Defined in:
- lib/link_toad.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#mapping ⇒ Object
readonly
Returns the value of attribute mapping.
Instance Method Summary collapse
-
#initialize(mapping) ⇒ LinkToad
constructor
mappingis a hash mapping from a URL to an identifier that should be associated with that URL. -
#match(url) ⇒ Object
Returns the identifiers for the document at the given
url.
Constructor Details
#initialize(mapping) ⇒ LinkToad
mapping is a hash mapping from a URL to an identifier that should be associated with that URL.
13 14 15 |
# File 'lib/link_toad.rb', line 13 def initialize(mapping) @mapping = mapping end |
Instance Attribute Details
#mapping ⇒ Object (readonly)
Returns the value of attribute mapping.
9 10 11 |
# File 'lib/link_toad.rb', line 9 def mapping @mapping end |
Instance Method Details
#match(url) ⇒ Object
Returns the identifiers for the document at the given url.
Identifiers are found by looking up links in the document in the mapping hash.
20 21 22 23 |
# File 'lib/link_toad.rb', line 20 def match(url) links = links_from_url(url) links.map { |l| hits_for_uri(l) }.flatten.uniq end |