Module: Conred::Video
Defined Under Namespace
Classes: Other, Vimeo, Youtube
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#error_message ⇒ Object
Returns the value of attribute error_message.
46
47
48
|
# File 'lib/conred/video.rb', line 46
def error_message
@error_message
end
|
#height ⇒ Object
Returns the value of attribute height.
46
47
48
|
# File 'lib/conred/video.rb', line 46
def height
@height
end
|
#video_id ⇒ Object
Returns the value of attribute video_id.
46
47
48
|
# File 'lib/conred/video.rb', line 46
def video_id
@video_id
end
|
#width ⇒ Object
Returns the value of attribute width.
46
47
48
|
# File 'lib/conred/video.rb', line 46
def width
@width
end
|
Class Method Details
.new(arguments) ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'lib/conred/video.rb', line 14
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
32
33
34
35
36
37
38
39
|
# File 'lib/conred/video.rb', line 32
def code
view_path = File.join(
File.dirname(__FILE__),
"../views/video/video_iframe.html.erb"
)
template = ERB.new(File.read(view_path))
template.result(binding)
end
|
#exist? ⇒ Boolean
41
42
43
44
|
# File 'lib/conred/video.rb', line 41
def exist?
response = Net::HTTP.get_response(URI("http:#{api_uri}"))
response.is_a?(Net::HTTPSuccess)
end
|
#initialize(options = {}) ⇒ Object
7
8
9
10
11
12
|
# File 'lib/conred/video.rb', line 7
def initialize(options = {})
@width = options.fetch(:width, 670)
@height = options.fetch(:height, 450)
@error_message = options.fetch(:error_message, "Invalid video url")
@video_id = get_video_id_from(options[:video_url])
end
|
#vimeo_video? ⇒ Boolean
28
29
30
|
# File 'lib/conred/video.rb', line 28
def vimeo_video?
is_a?(Video::Vimeo)
end
|
#youtube_video? ⇒ Boolean
24
25
26
|
# File 'lib/conred/video.rb', line 24
def youtube_video?
is_a?(Video::Youtube)
end
|