Sha256: e0cf783d420dcd5346ecd6cb44fe30c71ecdaa1480b2e67ed20add6a173885d4

Contents?: true

Size: 388 Bytes

Versions: 8

Compression:

Stored size: 388 Bytes

Contents

module Onebox
  class Matcher
    def initialize(link)
      @url = link
    end

    def ordered_engines
      @ordered_engines ||= Engine.engines.sort_by do |e|
        e.respond_to?(:priority) ? e.priority : 100
      end
    end

    def oneboxed
      uri = URI(@url)
      ordered_engines.find { |engine| engine === uri }
    rescue URI::InvalidURIError
      nil
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
onebox-1.7.7 lib/onebox/matcher.rb
onebox-1.7.6 lib/onebox/matcher.rb
onebox-1.7.5 lib/onebox/matcher.rb
onebox-1.7.4 lib/onebox/matcher.rb
onebox-1.7.3 lib/onebox/matcher.rb
onebox-1.7.2 lib/onebox/matcher.rb
onebox-1.7.1 lib/onebox/matcher.rb
onebox-1.7.0 lib/onebox/matcher.rb