Sha256: a626f1a5ef68a8894f63b3df3cd52565b565bf2d727a31f3e8b47df4b3e16f1b

Contents?: true

Size: 865 Bytes

Versions: 1

Compression:

Stored size: 865 Bytes

Contents

module VideojsRails
  module Tags
    class Caption < Tag
      def initialize(lang, default_language, options)
        @lang = lang.to_sym
        @default_language = default_language
        parse_options(options)
      end

      def to_html
        tag :track, attributes
      end

      private

      attr_reader :src, :label, :lang, :default_language

      def default?
        default_language == lang
      end

      def parse_options(options)
        case options
        when String, Symbol
          @src = options
        when Hash
          @src, @label = options.values_at(:src, :label)
        else
          raise ArgumentError
        end
      end

      def attributes
        {
          kind: :captions,
          src: src,
          srclang: lang,
          label: label,
          default: default?
        }
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
videojs_rails-4.12.15 lib/videojs_rails/tags/caption.rb