Module: Kabal::RussianRules::Declinations
- Defined in:
- lib/kabal/languages/russian/declinations.rb
Class Method Summary collapse
- .end_with_two_or_three_of_four?(count) ⇒ Boolean
- .ends_with_one?(count) ⇒ Boolean
- .name_with_declination(number_name, count) ⇒ Object
Class Method Details
.end_with_two_or_three_of_four?(count) ⇒ Boolean
29 30 31 |
# File 'lib/kabal/languages/russian/declinations.rb', line 29 def self.end_with_two_or_three_of_four?(count) count.to_s[-1] == "2" or count.to_s[-1] == "3" or count.to_s[-1] == "4" end |
.ends_with_one?(count) ⇒ Boolean
25 26 27 |
# File 'lib/kabal/languages/russian/declinations.rb', line 25 def self.ends_with_one?(count) count.to_s[-1] == "1" and (count % 100) / 10 != 1 end |
.name_with_declination(number_name, count) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/kabal/languages/russian/declinations.rb', line 4 def self.name_with_declination(number_name, count) #for 5.0e-11 like numbers #FIXME find another way to convert number from exp form if count.to_s.include? "e" count = count.to_s.split('.')[0].to_i end #FIXME add gem russian if number_name[-1, 1] == "а" return number_name if ends_with_one? count return number_name[0..4] + "и" if end_with_two_or_three_of_four? count number_name[0..4] elsif number_name[-1, 1] == "я" return number_name if ends_with_one? count number_name[0..-3] + "ых" else return number_name if ends_with_one? count return number_name + "а" if end_with_two_or_three_of_four? count number_name + "ов" end end |