Class: Embedda::Filters::Youtube
- Inherits:
-
Object
- Object
- Embedda::Filters::Youtube
- Defined in:
- lib/embedda/filters/youtube.rb
Instance Method Summary collapse
-
#initialize(protocol, width, height) ⇒ Youtube
constructor
A new instance of Youtube.
- #process(string) ⇒ Object
Constructor Details
#initialize(protocol, width, height) ⇒ Youtube
Returns a new instance of Youtube.
4 5 6 7 8 |
# File 'lib/embedda/filters/youtube.rb', line 4 def initialize(protocol, width, height) @protocol = protocol @width = width @height = height end |
Instance Method Details
#process(string) ⇒ Object
10 11 12 13 14 |
# 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 |