Sha256: c2ad8e20d51289f70fa61f035df335cf457bdcc911738ba33ae8d1f63b5c2f86

Contents?: true

Size: 843 Bytes

Versions: 5

Compression:

Stored size: 843 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.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="//#{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

5 entries across 5 versions & 1 rubygems

Version Path
onebox-2.0.2 lib/onebox/mixins/twitch_onebox.rb
onebox-2.0.1 lib/onebox/mixins/twitch_onebox.rb
onebox-2.0.0 lib/onebox/mixins/twitch_onebox.rb
onebox-1.9.30 lib/onebox/mixins/twitch_onebox.rb
onebox-1.9.29 lib/onebox/mixins/twitch_onebox.rb