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



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

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

#at(key, &fallback) ⇒ Object

Matches only one link



88
89
90
91
# File 'lib/leadlight/hyperlinkable.rb', line 88

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