class Frame
Constants
- URL_Formats
Public Class Methods
embed_url(vid, width = 420, height=315 )
click to toggle source
# File lib/tube_frame.rb, line 11 def self.embed_url(vid, width = 420, height=315 ) return nil if has_invalid_chars?(vid) if match = URL_Formats[:youtube].match(vid) vid_id = match[4] %(<iframe width="#{width}" height="#{height}" src="http://www.youtube.com/embed/#{vid_id}" frameborder="0" allowfullscreen></iframe>) elsif match = URL_Formats[:youtube_shortened].match(vid) vid_id = match[3] %(<iframe width="#{width}" height="#{height}" src="http://www.youtube.com/embed/#{vid_id}" frameborder="0" allowfullscreen></iframe>) elsif match = URL_Formats[:vimeo].match(vid) vid_id = match[3] %(<iframe src="//player.vimeo.com/video/#{vid_id}" width="#{width}" height="#{height}" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>) else return nil end end
has_invalid_chars?(vid)
click to toggle source
# File lib/tube_frame.rb, line 30 def self.has_invalid_chars?(vid) !URL_Formats[:invalid_chars].match(vid).nil? end