Sha256: e1c1f92ec5a1b2ad7ce97904a6b6852e86238aff9cfba993f317de823f02bd9d

Contents?: true

Size: 637 Bytes

Versions: 2

Compression:

Stored size: 637 Bytes

Contents

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

class FilmSnob
  attr_reader :url, :video

  def initialize(url)
    @url = url
    @video = FilmSnob::UrlToVideo.new(url).video
  end

  def watchable?
    !video.nil?
  end

  def method_missing(m)
    if [:site, :id, :clean_url, :title, :html].include?(m)
      complain_about_bad_urls!(m)
      video.send(m)
    else
      super
    end
  end

  private

    def complain_about_bad_urls!(method)
      raise NotSupportedURLError.new("Can not call FilmSnob##{method} because #{url} is not a supported URL.") unless watchable?
    end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
film_snob-0.2.1 lib/film_snob.rb
film_snob-0.2.0 lib/film_snob.rb