Sha256: bbf3c2d4d8dedf9f981081756d4bb6a2b2f0949c07c92c28e170a34872090152

Contents?: true

Size: 657 Bytes

Versions: 3

Compression:

Stored size: 657 Bytes

Contents

require "film_snob/coub"
require "film_snob/funny_or_die"
require "film_snob/hulu"
require "film_snob/vimeo"
require "film_snob/youtube"

class FilmSnob
  class UrlToVideo

    VIDEO_SITES = [
      Vimeo,
      YouTube,
      Hulu,
      FunnyOrDie,
      Coub
    ]

    attr_reader :url, :options

    def initialize(url, options)
      @url = url
      @options = options
    end

    def video
      site.nil?? nil : site.new(url, options)
    end

    private

      def site
        @site ||= VIDEO_SITES.find do |site|
          site.valid_url_patterns.any? do |pattern|
            pattern.match(url)
          end
        end
      end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
film_snob-0.3.9 lib/film_snob/url_to_video.rb
film_snob-0.3.8 lib/film_snob/url_to_video.rb
film_snob-0.3.7 lib/film_snob/url_to_video.rb