Sha256: f46b0404491d303ad70680ef117d119e9a8ae98fd2bfe5b3214b926e886f85e9

Contents?: true

Size: 833 Bytes

Versions: 5

Compression:

Stored size: 833 Bytes

Contents

module Convert
  module Converters

    def liveleak(string, options = {})
      options = {
        :width => 420,
        :height => 315,
        :frameborder => 0,
        :wmode => nil,
        :autoplay => false,
        :hide_related => false
      }.merge(options)

      @regex = %r{http://www\.liveleak\.com/(?:ll_embed|view)\?.=(\w+)}

      string.gsub(@regex) do
        a = []
        a << "wmode=#{options[:wmode]}" if options[:wmode]
        a << "autoplay=1" if options[:autoplay]
        a << "rel=0" if options[:hide_related]

        src = "http://www.liveleak.com/ll_embed?f=#{$1}"
        src += "?#{a.join '&'}" unless a.empty?

        %{<iframe width="#{options[:width]}" height="#{options[:height]}" src="#{src}" frameborder="#{options[:frameborder]}" allowfullscreen></iframe>}
      end
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
convert-0.1.7 lib/converters/liveleak.rb
convert-0.1.6 lib/converters/liveleak.rb
convert-0.1.5 lib/converters/liveleak.rb
convert-0.1.4 lib/converters/liveleak.rb
convert-0.1.3 lib/converters/liveleak.rb