Module: Conred::Video
Defined Under Namespace
Classes: Other, Vimeo, Youtube
Instance Attribute Summary collapse
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#video_id ⇒ Object
readonly
Returns the value of attribute video_id.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Class Method Summary collapse
Instance Method Summary collapse
- #code ⇒ Object
- #exist? ⇒ Boolean
- #initialize(options = {}) ⇒ Object
- #vimeo_video? ⇒ Boolean
- #youtube_video? ⇒ Boolean
Instance Attribute Details
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
46 47 48 |
# File 'lib/conred/video.rb', line 46 def @error_message end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
46 47 48 |
# File 'lib/conred/video.rb', line 46 def height @height end |
#video_id ⇒ Object (readonly)
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 (readonly)
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( = {}) @width = .fetch(:width, 670) @height = .fetch(:height, 450) @error_message = .fetch(:error_message, "Invalid video url") @video_id = get_video_id_from([:video_url]) end |