class Embedda::Filters::Youtube
Public Class Methods
new(protocol, width, height)
click to toggle source
# File lib/embedda/filters/youtube.rb, line 4 def initialize(protocol, width, height) @protocol = protocol @width = width @height = height end
Public Instance Methods
process(string)
click to toggle source
# File lib/embedda/filters/youtube.rb, line 10 def process(string) string.gsub!(/(<a[^>]*?youtube\.com\/watch\?v=([a-zA-Z0-9\-\_]+).*?<\/a>)/i) { |m| player($2) } string.gsub!(/([http|https]+:\/\/(?:www\.)?youtube\.com\/watch\?v=([a-zA-Z0-9\-\_]+)\w*)/i) { |m| player($2) } return string end
Private Instance Methods
player(token)
click to toggle source
# File lib/embedda/filters/youtube.rb, line 18 def player(token) %Q{<iframe width="#{@width}" height="#{@height}" src="#{@protocol}://www.youtube.com/embed/#{token}" frameborder="0" allowfullscreen></iframe>} end