Sha256: 0054cba36464cd798adad14da837d17af8589c99075fee33172864f8886b996c

Contents?: true

Size: 482 Bytes

Versions: 7

Compression:

Stored size: 482 Bytes

Contents

class Videos::YouTube < Videos::Video
  def embed_code
    content_tag(:iframe, '', type: 'text/html', width: width, height: height, src: src)
  end
  alias_method :to_html, :embed_code

  def id
    id = ''
    url = @uri.to_s.gsub(/(>|<)/i,'').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/)
    if url[2] != nil
      id = url[2].split(/[^0-9a-z_\-]/i)
      id = id[0];
    else
      id = url;
    end
    id
  end

  def src
    "https://www.youtube.com/embed/#{id}"
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rb42-videos-1.0.7 lib/videos/youtube.rb
rb42-videos-1.0.6 lib/videos/youtube.rb
rb42-videos-1.0.5 lib/videos/youtube.rb
rb42-videos-1.0.4 lib/videos/youtube.rb
rb42-videos-1.0.3 lib/videos/youtube.rb
rb42-videos-1.0.2 lib/videos/youtube.rb
rb42-videos-1.0.1 lib/videos/youtube.rb