Module: Conred::Video
Defined Under Namespace
Classes: Other, Vimeo, Youtube
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.new(arguments) ⇒ Object
13
14
15
16
17
18
19
20
21
|
# File 'lib/conred/video.rb', line 13
def self.new arguments
if Youtube.url_format_is_valid? arguments[:video_url]
Youtube.new arguments
elsif Video::Vimeo.url_format_is_valid? arguments[:video_url]
Vimeo.new arguments
else
Other.new arguments
end
end
|
Instance Method Details
#code ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/conred/video.rb', line 31
def code
render(
:video_link => video_link,
:height => @height,
:width => @width
).html_safe
end
|
#exist? ⇒ Boolean
39
40
41
42
|
# File 'lib/conred/video.rb', line 39
def exist?
response = Net::HTTP.get_response(URI("https:#{api_uri}"))
response.is_a?(Net::HTTPSuccess)
end
|
#initialize(arguments = {:width => 670, :height => 450, :error_message => "Video url you have provided is invalid"}) ⇒ Object
6
7
8
9
10
11
|
# File 'lib/conred/video.rb', line 6
def initialize(arguments = {:width => 670, :height => 450, :error_message => "Video url you have provided is invalid"})
@width = arguments[:width]
@height = arguments[:height]
@error_message = arguments[:error_message]
@video_id = get_video_id_from arguments[:video_url]
end
|
#vimeo_video? ⇒ Boolean
27
28
29
|
# File 'lib/conred/video.rb', line 27
def vimeo_video?
is_a?(Video::Vimeo)
end
|
#youtube_video? ⇒ Boolean
23
24
25
|
# File 'lib/conred/video.rb', line 23
def youtube_video?
is_a?(Video::Youtube)
end
|