Question about a function in Ruby

Hi guys,
I’m totally new to Ruby, did some PHP (don’t blame me :wink: and some JS but I need to understand this simple function. It sanitizes links but I have some issues to understand the full functionality.

I have to enhance the function but don’t know how: I want to enhance links in User-Generated-Content with " rel=“nofollow ugc” " … there’s already this function but it gives me a hard time to understand it.

def auto_link_urls_and_at_replies(str)
return unless str.present?
# Sanitize before we link
str = sanitize(str)
str.gsub!(Post.at_reply_regexp) do |match|
user = User.find_by_login(match[1…-1])
user ? (’@%s’ % [user.blog.verified_url, user.login]) : match
end
str.html_safe.auto_link
end

Thanks for your help.