Module: ToRussianWords
- Includes:
- Divisions, UnderHundred, Utils
- Included in:
- Fixnum, INTEGER_KLASS, String
- Defined in:
- lib/to_russian_words.rb,
lib/to_russian_words/utils.rb,
lib/to_russian_words/version.rb,
lib/to_russian_words/divisions.rb,
lib/to_russian_words/under_hundred.rb,
lib/to_russian_words/russian_gender_labels.rb
Defined Under Namespace
Modules: Divisions, RussianGenderLabels, UnderHundred, Utils
Constant Summary collapse
- VERSION =
'1.1.4'
Constants included from RussianGenderLabels
RussianGenderLabels::DATIVE_RUSSIAN_FEMALE_LABEL, RussianGenderLabels::NOMINATIVE_RUSSIAN_FEMALE_LABEL
Constants included from Divisions
Divisions::DATIVE_DIVISIONS, Divisions::NOMINATIVE_DIVISIONS
Constants included from UnderHundred
UnderHundred::DATIVE_UNDER_HUNDRED, UnderHundred::NOMINATIVE_UNDER_HUNDRED
Instance Method Summary collapse
- #to_russian_words(russian_case = 'nominative') ⇒ Object
- #to_words(russian_case = 'nominative') ⇒ Object
Methods included from Utils
#check_sign, #divisions, #higher_than_hundred, #hundred_name, #numerical?, #result_below_one_thousand, #under_hundred
Instance Method Details
#to_russian_words(russian_case = 'nominative') ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/to_russian_words.rb', line 16 def to_russian_words(russian_case = 'nominative') num = numerical?(self) num, sign = check_sign(num) return (sign + under_hundred(russian_case)[num]) if num <= 100 counter = 0 result = [] while num != 0 num, remaining = num.divmod(1000) temp_result = result_below_one_thousand(remaining, counter, russian_case) result << temp_result + ' ' + divisions(russian_case)[counter][remaining.to_s.last.to_i] if temp_result counter += 1 end sign + result.reverse.join(' ').rstrip end |
#to_words(russian_case = 'nominative') ⇒ Object
12 13 14 |
# File 'lib/to_russian_words.rb', line 12 def to_words(russian_case = 'nominative') to_russian_words(russian_case) end |