farsifu is a toolbox for developing ruby applications in Persian (Farsi) language.
- Converting numbers to and from Persian numbers
- Spelling numbers in Persian (supports ordinal spelling of numbers in Persian)
- Converting Persian spelling of numbers back to normal numbers (see examples below)
- List of Iran's provinces, cities and counties
- List of countries in Persian
"1234567890,;".to_farsi # => "۱۲۳۴۵۶۷۸۹۰،؛"
"۱۲۳۴۵۶۷۸۹۰،؛".to_english # => "1234567890,;"
1024.spell_farsi # => "یک هزار و بیست و چهار"
-2567023.spell_farsi # => "منفی دو میلیون و پانصد و شصت و هفت هزار و بیست و سه"
7.53.spell_farsi # => "هفت ممیز پنجاه و سه صدم"
-0.999.spell_farsi # => "منفی صفر ممیز نهصد و نود و نه هزارم"
# Passing false to spell_farsi method will turn off the verbose mode.
-0.999.spell_farsi(false) # => "منفی نهصد و نود و نه هزارم"
12.spell_ordinal_farsi # => "دوازدهم"
# Note the different when you pass true to spell_ordinal_farsi method.
12.spell_ordinal_farsi(true) # => "دوازدهمین"
"هزار و چهل و پنج".farsi_to_number # => 1045
Iran::Provinces
# => returns an array of hashes like below
# [{:name => "آذربایجان شرقی", :eng_name => "Azerbaijan, East",
# :capital => "تبریز", :eng_capital => "Tabriz",
# :counties => ["آذرشهر", "اسکو",..."]...]
Iran::Countries
# => returns an array of hashes like below
# [ { :iso2 => 'AI', :fa => 'آنگیل', :en => 'Anguilla' }, ...]
gem install farsifu
- No public API changes
- Enable frozen string literal to speed up Ruby
- Update rspec and refactor tests to version 3.9
- Drop official support for Ruby < 2.4.0 (the Gem might work on older versions, but it's not tested)
- Enable travis-ci to run tests on supported ruby versions
- Enable and configure rubocop
- Arash Mousavi is now a collaborator.
- Passing false to spell_farsi method will turn off the verbose mode.
- Major internal refactoring. Should not change the external API.
- Added
farsi_to_number
to convert farsi spelling of numbers to real numbers , courtesy of Arash Mousavi - Major refactoring and reorganization of the code, courtesy of Arash Mousavi
- Added Farsi ordinal spelling, courtesy of Arash Mousavi
- Added ruby 1.9 compatibility, courtesy of Brian Kaney
- Updated Readme
- Updated rspec to 2.4
- No longer replacing * with ×
- Renamed gem from FarsiFu to farsifu
- Added a spec suite
- Migrated the gem to rubygems.org
- Added Iran Module
- Converted into a gem
- Added rdocs documentation
- Initial release
Copyright (c) 2009-2013 Allen Bargi. See LICENSE for details.