Sha256: 5ba3c153d44406f356d401dfe73b08cbc302f348e085ec07497481dad306eb41

Contents?: true

Size: 630 Bytes

Versions: 1

Compression:

Stored size: 630 Bytes

Contents

module VideojsRubyRails
  module Tags
    class Source < Tag
      def initialize(video_type, options)
        @video_type = video_type
        @attributes = parse_options(options)
      end

      def to_html
        tag :source, @attributes
      end

      private

      attr_reader :video_type

      def parse_options(options)
        case options
        when String, Symbol
          {
            src: options,
            type: type
          }
        when Hash
          options
        else
          raise ArgumentError
        end
      end

      def type
        "video/#{video_type}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
videojs_ruby_rails-6.2.8 lib/videojs_ruby_rails/tags/source.rb