Sha256: 829245516089abf97c2bed40dd51ad7726954b99b076b498b76664672a2d683b

Contents?: true

Size: 914 Bytes

Versions: 21

Compression:

Stored size: 914 Bytes

Contents

# frozen_string_literal: true

module Onebox
  module Mixins
    module TwitchOnebox

      def self.included(klass)
        klass.include(Onebox::Engine)
        klass.matches_regexp(klass.twitch_regexp)
        klass.requires_iframe_origins "https://player.twitch.tv"
        klass.include(InstanceMethods)
      end

      module InstanceMethods
        def twitch_id
          @url.match(self.class.twitch_regexp)[1]
        end

        def base_url
          "player.twitch.tv/?"
        end

        def placeholder_html
          ::Onebox::Helpers.video_placeholder_html
        end

        def to_html
          <<~HTML
          <iframe src="https://#{base_url}#{query_params}&parent=#{options[:hostname]}&autoplay=false" width="620" height="378" frameborder="0" style="overflow: hidden;" scrolling="no" allowfullscreen="allowfullscreen"></iframe>
          HTML
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
onebox-2.2.12 lib/onebox/mixins/twitch_onebox.rb
onebox-2.2.11 lib/onebox/mixins/twitch_onebox.rb
onebox-2.2.10 lib/onebox/mixins/twitch_onebox.rb
onebox-2.2.9 lib/onebox/mixins/twitch_onebox.rb
onebox-2.2.8 lib/onebox/mixins/twitch_onebox.rb
onebox-2.2.6 lib/onebox/mixins/twitch_onebox.rb
onebox-2.2.5 lib/onebox/mixins/twitch_onebox.rb
onebox-2.2.4 lib/onebox/mixins/twitch_onebox.rb
onebox-2.2.2 lib/onebox/mixins/twitch_onebox.rb
onebox-2.2.1 lib/onebox/mixins/twitch_onebox.rb
onebox-2.2.0 lib/onebox/mixins/twitch_onebox.rb
onebox-2.1.9 lib/onebox/mixins/twitch_onebox.rb
onebox-2.1.8 lib/onebox/mixins/twitch_onebox.rb
onebox-2.1.7 lib/onebox/mixins/twitch_onebox.rb
onebox-2.1.6 lib/onebox/mixins/twitch_onebox.rb
onebox-2.1.5 lib/onebox/mixins/twitch_onebox.rb
onebox-2.1.4 lib/onebox/mixins/twitch_onebox.rb
onebox-2.1.3 lib/onebox/mixins/twitch_onebox.rb
onebox-2.1.2 lib/onebox/mixins/twitch_onebox.rb
onebox-2.1.1 lib/onebox/mixins/twitch_onebox.rb