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 19 20 21 22 23 24 25 26 |
# File 'lib/onebox/matcher.rb', line 13 def oneboxed uri = URI(@url) # A onebox needs a path or query string to be considered return if (uri.query.nil? || uri.query.size == 0) && (uri.path.size == 0 || uri.path == "/") ordered_engines.select do |engine| engine === uri end.first rescue URI::InvalidURIError # If it's not a valid URL, don't even match nil end |