Sha256: 254a7fed4e460f23ed766bf8cc42b864d57a85185ef2fa8299eb2ce30ae8a1e7

Contents?: true

Size: 678 Bytes

Versions: 1

Compression:

Stored size: 678 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 site
    complain_about_bad_urls!(:site)
    video.site
  end

  def id
    complain_about_bad_urls!(:id)
    video.id
  end

  def clean_url
    complain_about_bad_urls!(:clean_url)
    video.clean_url
  end

  def watchable?
    !video.nil?
  end

  private

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

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
film_snob-0.1.0 lib/film_snob.rb