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.5'
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, #get_division, #get_label, #higher_than_hundred, #hundred_name, #numerical?, #pluralize, #result_below_one_thousand, #under_hundred
Instance Method Details
#to_russian_words(russian_case = "nominative") ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/to_russian_words.rb', line 17 def to_russian_words(russian_case = "nominative") num = numerical?(self) num, sign = check_sign(num) return (sign + get_label(russian_case: russian_case, remaining: 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 + " " + get_division(russian_case, counter, remaining) if temp_result counter += 1 end sign + result.reverse.join(" ").rstrip end |
#to_words(russian_case = "nominative") ⇒ Object
13 14 15 |
# File 'lib/to_russian_words.rb', line 13 def to_words(russian_case = "nominative") to_russian_words(russian_case) end |