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 |
# File 'lib/onebox/matcher.rb', line 13 def oneboxed uri = URI(@url) return unless uri.port.nil? || Onebox..allowed_ports.include?(uri.port) return unless uri.scheme.nil? || Onebox..allowed_schemes.include?(uri.scheme) ordered_engines.find { |engine| engine === uri } rescue URI::InvalidURIError nil end |