Class: LinkToad

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

Direct Known Subclasses

MusicArtistsLinkToad

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#mappingObject (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