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
27 28 29 |
# File 'lib/kabal/languages/russian/declinations.rb', line 27 def self.end_with_two_or_three_of_four?(count) count.to_s[-1] == '2' || count.to_s[-1] == '3' || count.to_s[-1] == '4' end |
.ends_with_one?(count) ⇒ Boolean
23 24 25 |
# File 'lib/kabal/languages/russian/declinations.rb', line 23 def self.ends_with_one?(count) count.to_s[-1] == '1' && (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 |
# File 'lib/kabal/languages/russian/declinations.rb', line 4 def self.name_with_declination(number_name, count) 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 |