lib/film_snob.rb in film_snob-0.3.4 vs lib/film_snob.rb in film_snob-0.3.5
- old
+ new
@@ -1,37 +1,40 @@
require "film_snob/version"
require "film_snob/url_to_video"
require "film_snob/exceptions"
class FilmSnob
- attr_reader :url, :video
+ attr_reader :url
def initialize(url, options={})
@url = url
@video = UrlToVideo.new(url, options).video
end
def watchable?
- !video.nil?
+ !@video.nil?
end
def method_missing(message)
if delegated_video_methods.include?(message)
- complain_about_bad_urls!(message)
video.send(message)
else
super
end
end
private
-
- def delegated_video_methods
- [:site, :id, :clean_url, :title, :html]
+
+ def video
+ if watchable?
+ @video
+ else
+ raise NotSupportedURLError.new("#{url} is not a supported URL")
+ end
end
- def complain_about_bad_urls!(method)
- raise NotSupportedURLError.new("Can not call FilmSnob##{method} because #{url} is not a supported URL.") unless watchable?
+ def delegated_video_methods
+ [:site, :id, :clean_url, :title, :html]
end
end