Remove accents from String
s easily, using new Ruby 2.x Refinements
.
Add this line to your application's Gemfile:
gem 'accentless'
And then execute:
$ bundle
Or install it yourself as:
$ gem install accentless
require 'accentless'
class Word
using Accentless
def initialize(word)
@word = word
end
def value
# you can use String#accentless! method which
# modifies original String
@word.accentless
end
end
Word.new("São Paulo").value #=> Sao Paulo
You can contribute easily too:
- Fork it ( http://github.com/lucasas/accentless/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request