Sha256: 029bead5c9d359ac1245c35c2b5b44838458690c4885092d450611ecea1e6ccd

Contents?: true

Size: 626 Bytes

Versions: 1

Compression:

Stored size: 626 Bytes

Contents

module VideojsRails
  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_rails-4.12.15 lib/videojs_rails/tags/source.rb