Class: Onebox::Matcher
- Inherits:
-
Object
- Object
- Onebox::Matcher
- Defined in:
- lib/onebox/matcher.rb
Instance Method Summary collapse
-
#initialize(link) ⇒ Matcher
constructor
A new instance of Matcher.
- #oneboxed ⇒ Object
- #ordered_engines ⇒ Object
Constructor Details
#initialize(link) ⇒ Matcher
Returns a new instance of Matcher.
3 4 5 |
# File 'lib/onebox/matcher.rb', line 3 def initialize(link) @url = link end |
Instance Method Details
#oneboxed ⇒ Object
13 14 15 16 17 18 |
# File 'lib/onebox/matcher.rb', line 13 def oneboxed uri = URI(@url) ordered_engines.find { |engine| engine === uri } rescue URI::InvalidURIError nil end |
#ordered_engines ⇒ Object
7 8 9 10 11 |
# File 'lib/onebox/matcher.rb', line 7 def ordered_engines @ordered_engines ||= Engine.engines.sort_by do |e| e.respond_to?(:priority) ? e.priority : 100 end end |