class MultimediaParadise::YoutubeEmbedder
Constants
- DEFAULT_URL
#¶ ↑
DEFAULT_URL
¶ ↑#¶ ↑
Attributes
params[RW]
provider[RW]
uri[RW]
Public Class Methods
new(link, run_already = true)
click to toggle source
Public Instance Methods
determine_params(i = @uri)
click to toggle source
#¶ ↑
determine_params
¶ ↑
We must be careful here - the input should be a string.
#¶ ↑
# File lib/multimedia_paradise/video/youtube_embedder.rb, line 110 def determine_params(i = @uri) @params = Hash[*i.query.split('&').map {|entry| splitted = entry.split('=') splitted[0] = splitted.first.to_sym # First entry becomes a symbol splitted }.flatten] end
determine_provider(i = @uri)
click to toggle source
embed( dimensions = @width+'x'+@height, options = {} )
click to toggle source
#¶ ↑
embed¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/youtube_embedder.rb, line 63 def embed( dimensions = @width+'x'+@height, options = {} ) options[:load] = true if options[:load].nil? if dimensions.include? 'x' h, w = dimensions.split('x') else h = w = dimensions # Assume '50' as input actually means '50x50'. end if youtube? @embed = %( <iframe width="#{h}" height="#{w}" #{options[:load] ? 'src' : 'data-src'}="http://www.youtube.com/embed/#{id}?html5=1" ) # Process the @options next. options.each {| key, value| next if key == :load @embed << %( data-#{key}="#{value}" ) } @embed << %( frameborder="0" allowfullscreen></iframe>) else @embed << 'NOT FOUND ANYTHING.<br>' end end
embed?()
click to toggle source
#¶ ↑
embed?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/youtube_embedder.rb, line 91 def embed? @embed end
Also aliased as: embedded_string?
feedback()
click to toggle source
#¶ ↑
feedback¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/youtube_embedder.rb, line 155 def feedback lpad = 32 e 'Now testing some components for '+simp(url?)+':' e ('The id is: ').ljust(lpad)+sfancy(id) e ('The provider is: ').ljust(lpad)+sfancy(provider.to_s) e ('The thumbnail is: ').ljust(lpad)+sfancy(thumbnail) e e 'And to embed this into your webpage, use this code here:'+N+N e ' '+embed e N+N end
id?()
click to toggle source
#¶ ↑
id?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/youtube_embedder.rb, line 141 def id? params[:v] if youtube? end
Also aliased as: id
parse_uri(i = @link)
click to toggle source
reset()
click to toggle source
run()
click to toggle source
set_height(i)
click to toggle source
set_link(i = nil)
click to toggle source
set_width(i)
click to toggle source
thumbnail(size = :default)
click to toggle source
#¶ ↑
thumbnail¶ ↑
Give back a thumbnail of the youtube video.
Each YouTube video has 4 generated images.
They are predictably formatted as follows:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg
#¶ ↑
# File lib/multimedia_paradise/video/youtube_embedder.rb, line 208 def thumbnail(size = :default) if youtube? "http://img.youtube.com/vi/#{id?}/0.jpg" end end
url?()
click to toggle source