Sha256: 2f3c9ee5d4a69deeddf83e9189ee19b29fa97885bf3ea1e6e67bb9bf41165406

Contents?: true

Size: 767 Bytes

Versions: 4

Compression:

Stored size: 767 Bytes

Contents

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

class FilmSnob
  attr_reader :url

  extend Deprecated

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

  def embeddable?
    !@video.nil?
  end

  deprecated_alias :watchable?, :embeddable?, removed_in: "v1.0.0"

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

  private

  def video
    if embeddable?
      @video
    else
      raise NotSupportedURLError, "#{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.6.1 lib/film_snob.rb
film_snob-0.6.0 lib/film_snob.rb
film_snob-0.5.0 lib/film_snob.rb
film_snob-0.4.0 lib/film_snob.rb