Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/autolinker.rb

Instance Method Summary collapse

Instance Method Details



2
3
4
5
# File 'lib/autolinker.rb', line 2

def autolink
    pattern = /(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$])/i
    self.gsub(pattern) { |s| "<a href='#{s}'>#{s}</a>" }
end