module Translate
Constants
- DIGITS_LIMIT
Set the limit of translated number of digits
Public Instance Methods
in_english()
click to toggle source
# File lib/modules/translate.rb, line 5 def in_english return nil if over_limit? num < 0 ? "minus-#{in_words}" : in_words end
Private Instance Methods
digits_count()
click to toggle source
# File lib/modules/translate.rb, line 30 def digits_count in_array.count end
formatted_num()
click to toggle source
# File lib/modules/translate.rb, line 46 def formatted_num num.abs.to_i end
in_array()
click to toggle source
# File lib/modules/translate.rb, line 26 def in_array formatted_num.to_s.split(//) end
in_words()
click to toggle source
# File lib/modules/translate.rb, line 21 def in_words return single_digits(formatted_num) unless digits_count > 1 "#{single_digits(digits_count).capitalize}Digits".constantize.send(:run, formatted_num) end
numbers_in_words()
click to toggle source
# File lib/modules/translate.rb, line 17 def numbers_in_words return YAML.load_file(File.join(File.dirname(File.expand_path(__FILE__)), 'languages/english_numbers.yml')) end
over_limit?()
click to toggle source
# File lib/modules/translate.rb, line 13 def over_limit? digits_count > DIGITS_LIMIT end
power_of_ten()
click to toggle source
# File lib/modules/translate.rb, line 34 def power_of_ten digits_count - 1 end
prefix(number)
click to toggle source
# File lib/modules/translate.rb, line 42 def prefix(number) numbers_in_words['powers'][number] end
single_digits(number)
click to toggle source
# File lib/modules/translate.rb, line 38 def single_digits(number) numbers_in_words['ones'][number] end