Sha256: 04d37149639125d61b550b43360e7f891763799cedfb1ca35291c3d873c9ad31

Contents?: true

Size: 668 Bytes

Versions: 4

Compression:

Stored size: 668 Bytes

Contents

require "film_snob/version"
require "film_snob/url_to_video"
require "film_snob/exceptions"

class FilmSnob
  attr_reader :url

  def initialize(url, options={})
    @url = url
    @video = UrlToVideo.new(url, options).video
  end

  def watchable?
    !@video.nil?
  end

  def method_missing(message)
    if delegated_video_methods.include?(message)
      video.send(message)
    else
      super
    end
  end

  private

    def video
      if watchable?
        @video
      else
        raise NotSupportedURLError.new("#{url} is not a supported URL")
      end
    end

    def delegated_video_methods
      [:site, :id, :clean_url, :title, :html]
    end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
film_snob-0.3.8 lib/film_snob.rb
film_snob-0.3.7 lib/film_snob.rb
film_snob-0.3.6 lib/film_snob.rb
film_snob-0.3.5 lib/film_snob.rb