Turkish character support for some standard Ruby methods. This gem provide support for these methods:
String#upcase
String#upcase!
String#downcase
String#downcase!
String#capitalize
String#capitalize!
String#swapcase
String#swapcase!
String#casecmp
Array#sort
Also gives you some new methods like:
String#titleize
- Ruby >= 2.0.0
- Rails >= 4.0.0
Notice: TurkishSupport uses refinements instead of monkey patching. Refinements come with Ruby 2.0.0 as a new feature and also, it is an experimental feature for now. If you want to more information about refinements, you can see the doc at http://www.ruby-doc.org/core-2.0.0/doc/syntax/refinements_rdoc.html
Add this line to your application's Gemfile:
gem 'turkish_support'
And then execute:
$ bundle
Or install it yourself as:
$ gem install turkish_support
After the installation of the gem, you should follow these steps.
- You need require it.
Note: If you are using a framework like Rails, you don't need to require, because it is already required by the framework.
require TurkishSupport
- Add
using TurkishSupport
line to the top of the scope, not inside of any class or module.
using TurkishSupport
Within the file which you added using TurkishSupport
line to the top of the scope; you can use core methods like below:
str = 'Bağcılar'
str.upcase #=> "BAĞCILAR"
str #=> "Bağcılar"
str = "İSMAİL"
str.downcase! #=> "ismail"
str #=> "ismail"
"merhaba".capitalize #=> "Merhaba"
["iki", "üç", "dört", "ılık", "iğne", "iyne"].sort #=> ["dört", "ılık", "iğne", "iki", "iyne", "üç"]
Note: If you also want to use original set of the core methods in the same scope, you can use send
method like this:
str = 'Bağcılar'
str.send(:upcase) #=> "BAğCıLAR"
- Fork it ( http://github.com/sbagdat/turkish_support/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