Class: EmbedRb::Url
- Inherits:
-
Object
- Object
- EmbedRb::Url
- Defined in:
- lib/embedrb/embed_url.rb
Overview
input = “hoge www.youtubue.com/watch?a=b donen hoge.fug/d” url = Embed::Url.new(input, => {:target => ‘_blank’}) print(url.process)
Instance Method Summary collapse
-
#initialize(input, output, options, embeds) ⇒ Url
constructor
A new instance of Url.
- #process ⇒ Object
Constructor Details
#initialize(input, output, options, embeds) ⇒ Url
Returns a new instance of Url.
8 9 10 11 12 |
# File 'lib/embedrb/embed_url.rb', line 8 def initialize(input, output, , ) @input = input = @url_regex = EmbedRb.url_regex end |
Instance Method Details
#process ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/embedrb/embed_url.rb', line 14 def process() config = EmbedRb.option(, :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 |