class EmbedRb::Url
input = “hoge www.youtubue.com/watch?a=b donen hoge.fug/d” url = Embed::Url.new(input, {:linkOptions => {:target => '_blank'}}) print(url.process)
Public Class Methods
new(input, output, options, embeds)
click to toggle source
# File lib/embedrb/embed_url.rb, line 8 def initialize(input, output, options, embeds) @input = input @options = options @url_regex = EmbedRb.url_regex end
Public Instance Methods
process()
click to toggle source
# File lib/embedrb/embed_url.rb, line 14 def process() config = EmbedRb.option(@options, :linkOptions) @input.gsub(@url_regex) {|match| extention = nil if match.include?(".") extention = match[match.rindex(".")+1, match.length].downcase end if config[:exclude].include? extention match else "<a href=\"#{EmbedRb.to_url(match)}\" rel=\"#{config[:rel]}\" target=\"#{config[:target]}\">#{match}</a>" end } end