Class: Leadlight::Hyperlinkable::LinkSet

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/leadlight/hyperlinkable.rb

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object

Match links on rel or title



76
77
78
# File 'lib/leadlight/hyperlinkable.rb', line 76

def [](key)
  self.class.new(select(&link_matcher(key)))
end

#at(key, &fallback) ⇒ Object

Matches only one link



81
82
83
84
# File 'lib/leadlight/hyperlinkable.rb', line 81

def at(key, &fallback)
  fallback ||= -> do raise KeyError, "No link matches #{key.inspect}" end
  detect(fallback, &link_matcher(key))
end