Class: Workarea::Storefront::VideoEmbedder
- Inherits:
-
Object
- Object
- Workarea::Storefront::VideoEmbedder
- Defined in:
- app/services/workarea/storefront/video_embedder.rb,
app/services/workarea/storefront/video_embedder/vimeo.rb,
app/services/workarea/storefront/video_embedder/youtube.rb
Defined Under Namespace
Instance Method Summary collapse
- #iframe_attrs ⇒ Object
-
#initialize(embed_code, options = {}) ⇒ VideoEmbedder
constructor
A new instance of VideoEmbedder.
- #vimeo? ⇒ Boolean
- #youtube? ⇒ Boolean
Constructor Details
#initialize(embed_code, options = {}) ⇒ VideoEmbedder
Returns a new instance of VideoEmbedder.
4 5 6 7 |
# File 'app/services/workarea/storefront/video_embedder.rb', line 4 def initialize(, = {}) @embed_code = Nokogiri::HTML.fragment().children.first @options = end |
Instance Method Details
#iframe_attrs ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/services/workarea/storefront/video_embedder.rb', line 9 def iframe_attrs attrs = { frameborder: '0', allowfullscreen: '', container_style: "padding-bottom: #{aspect_ratio}%" } = if vimeo? Vimeo.new(@embed_code, @options) elsif youtube? Youtube.new(@embed_code, @options) end attrs.merge(.attrs) end |
#vimeo? ⇒ Boolean
25 26 27 |
# File 'app/services/workarea/storefront/video_embedder.rb', line 25 def vimeo? host =~ /vimeo/ ? true : false end |
#youtube? ⇒ Boolean
29 30 31 |
# File 'app/services/workarea/storefront/video_embedder.rb', line 29 def youtube? host =~ /youtube/ ? true : false end |