Class: Workarea::Storefront::VideoEmbedder::Youtube
- Inherits:
-
Object
- Object
- Workarea::Storefront::VideoEmbedder::Youtube
- Defined in:
- app/services/workarea/storefront/video_embedder/youtube.rb
Instance Method Summary collapse
- #attrs ⇒ Object
-
#initialize(embed_code, options = {}) ⇒ Youtube
constructor
A new instance of Youtube.
- #url_params ⇒ Object
Constructor Details
#initialize(embed_code, options = {}) ⇒ Youtube
Returns a new instance of Youtube.
5 6 7 8 |
# File 'app/services/workarea/storefront/video_embedder/youtube.rb', line 5 def initialize(, = {}) @embed_code = @options = end |
Instance Method Details
#attrs ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/services/workarea/storefront/video_embedder/youtube.rb', line 10 def attrs { id: "youtube-#{youtube_id}", src: "#{url}?#{url_params}", data: { youtube_api: { mute: @options[:mute] }.to_json } } end |
#url_params ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'app/services/workarea/storefront/video_embedder/youtube.rb', line 22 def url_params parsed_query = Rack::Utils.parse_query(uri.query) parsed_query['enablejsapi'] = 1 parsed_query['autoplay'] = autoplay parsed_query['loop'] = loop_playback parsed_query['videoId'] = youtube_id URI.encode_www_form(parsed_query) end |