Sha256: 69a7b566043284bb95a7f3602c615634b8fb88c8daa0a60de2eba13c096403b4

Contents?: true

Size: 835 Bytes

Versions: 1

Compression:

Stored size: 835 Bytes

Contents

require 'action_view'

class Videos::Video
  include ActionView::Helpers::TagHelper
  include ActionView::Helpers::TextHelper
  include ActionView::Context
  attr_reader :uri
  attr_accessor :options

  DEFAULTS = {
    width: 640,
    height: 360,
    controls: true
  }
  def initialize(uri,options={})
    @uri = uri
    @options = DEFAULTS.merge(options)
  end

  def embed_code
    content_tag(:video, '', controls: controls) do
      concat(tag(:source, src: @uri.to_s, type: @uri.content_type))
      concat(content_tag(:span, sorry_message, class: 'sorry'))
    end
  end
  alias_method :to_html, :embed_code

  def sorry_message
    "I'm sorry; your browser doesn't support HTML5 video."
  end

  def width
    @options[:width]
  end

  def height
    @options[:height]
  end

  def controls
    @options[:controls]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rb42-videos-1.0.2 lib/videos/video.rb