# String Awesome
[](https://travis-ci.org/tiagopog/string_awesome)
[](https://codeclimate.com/repos/52a5452b7e00a4670f00b139/feed)
[](https://gemnasium.com/tiagopog/string_awesome)
[](http://badge.fury.io/rb/string_awesome)
This gem adds some awesome and easy-to-use extensions to Ruby String class.
## Installation
Compatible with Ruby 1.9.3+
Add this line to your application's Gemfile:
gem 'string_awesome'
And then execute:
$ bundle
Or install it yourself as:
$ gem install string_awesome
## Usage
### HTML
#### String#linkify
Finds URLs in the text and wrap in anchor tag.
``` ruby
'Awesome site: http://foobar.com'.linkify
#=> 'Awesome site: http://foobar.com'
'www.foobar.com'.linkify
#=> 'www.foobar.com'
'Awesome site: http://foobar.com'.linkify(class: 'link', truncate: 10)
#=> 'Awesome site: http://foo...'
'Awesome site: http://foobar.com'.linkify(class: 'link', target: '_blank')
#=> 'Awesome site: http://foobar.com'
'Awesome site: http://foobar.com'.linkify(truncate: { length: 10, html_encoded: true })
#=> 'Awesome site: http://foo…'
```
#### String#tweetify
Finds URLs, Twitter handles, hashtags in the text and wrap in anchor tag.
``` ruby
'What about to follow @tiagopog?'.tweetify
#=> 'What about to follow @tiagopog?'
"Let's code! #rubyrocks".tweetify
#=> "Let's code! #rubyrocks"
'Cool link from @tiagopog! http://foobar.com #rubyrocks'.tweetify(only: [:hashtag])
#=> 'Cool link from @tiagopog! http://foobar.com #rubyrocks'
'Cool link from @tiagopog! http://foobar.com #rubyrocks'.tweetify(only: [:hashtag, :tt_handle])
#=> 'Cool link from @tiagopog! http://foobar.com #rubyrocks'
```
#### String#nl2br
Replaces \n to \
tags.
``` ruby
"Hello
world!".nl2br
#=> "Hello
world!"
```
#### String#strip_tags
Removes all HTML tags from text.
``` ruby
'