Class: Preprocessor::Video::YouTube
- Inherits:
-
Object
- Object
- Preprocessor::Video::YouTube
- Defined in:
- lib/preprocessor/video.rb
Constant Summary collapse
- URL_REGEXP =
/youtube\.com\/(?:watch\?v=|v\/)([^\/?&]+)/i
Instance Attribute Summary collapse
-
#height ⇒ Object
Returns the value of attribute height.
-
#src ⇒ Object
Returns the value of attribute src.
-
#width ⇒ Object
Returns the value of attribute width.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options) ⇒ YouTube
constructor
A new instance of YouTube.
- #tag ⇒ Object
Constructor Details
#initialize(options) ⇒ YouTube
13 14 15 16 17 |
# File 'lib/preprocessor/video.rb', line 13 def initialize() self.src = [:src] self.width = [:width] || 465 self.height = [:height] || 344 end |
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height.
10 11 12 |
# File 'lib/preprocessor/video.rb', line 10 def height @height end |
#src ⇒ Object
Returns the value of attribute src.
10 11 12 |
# File 'lib/preprocessor/video.rb', line 10 def src @src end |
#width ⇒ Object
Returns the value of attribute width.
10 11 12 |
# File 'lib/preprocessor/video.rb', line 10 def width @width end |
Class Method Details
.recognizes?(src) ⇒ Boolean
25 26 27 |
# File 'lib/preprocessor/video.rb', line 25 def self.recognizes?(src) src =~ URL_REGEXP end |
Instance Method Details
#tag ⇒ Object
19 20 21 22 23 |
# File 'lib/preprocessor/video.rb', line 19 def tag if src =~ URL_REGEXP %{<iframe width="#{width}" height="#{height}" src="https://www.youtube-nocookie.com/embed/#{$1}" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>} end end |