Module: NumbersInWords
- Extended by:
- Forwardable
- Defined in:
- lib/numbers_in_words.rb,
lib/numbers_in_words/writer.rb,
lib/numbers_in_words/to_word.rb,
lib/numbers_in_words/version.rb,
lib/numbers_in_words/fraction.rb,
lib/numbers_in_words/duck_punch.rb,
lib/numbers_in_words/number_group.rb,
lib/numbers_in_words/powers_of_ten.rb,
lib/numbers_in_words/parsing/special.rb,
lib/numbers_in_words/parsing/to_number.rb,
lib/numbers_in_words/exceptional_numbers.rb,
lib/numbers_in_words/parsing/pair_parsing.rb,
lib/numbers_in_words/parsing/parse_status.rb,
lib/numbers_in_words/parsing/number_parser.rb,
lib/numbers_in_words/parsing/parse_fractions.rb,
lib/numbers_in_words/parsing/fraction_parsing.rb,
lib/numbers_in_words/parsing/parse_individual_number.rb
Defined Under Namespace
Modules: FractionParsing, NumericExtension, StringExtension
Classes: ExceptionalNumbers, Fraction, NumberGroup, NumberParser, PairParsing, ParseFractions, ParseIndividualNumber, ParseStatus, Special, ToNumber, ToWord, Writer
Constant Summary
collapse
- LENGTH_OF_GOOGOL =
length of the string i.e. one with 100 zeros
101
- Error =
::Class.new(::StandardError)
- AmbiguousParsingError =
::Class.new(Error)
- DivideByZeroError =
::Class.new(Error)
- InvalidNumber =
::Class.new(Error)
- EPSILON =
Arbitrarily small number for rationalizing fractions
0.0000000001
- VERSION =
'0.5.1'
- GOOGOL =
10**100
- POWERS_OF_TEN =
{
0 => 'one',
1 => 'ten',
2 => 'hundred',
1 * 3 => 'thousand',
2 * 3 => 'million',
3 * 3 => 'billion',
4 * 3 => 'trillion',
5 * 3 => 'quadrillion',
6 * 3 => 'quintillion',
7 * 3 => 'sextillion',
8 * 3 => 'septillion',
9 * 3 => 'octillion',
10 * 3 => 'nonillion',
11 * 3 => 'decillion',
12 * 3 => 'undecillion',
13 * 3 => 'duodecillion',
14 * 3 => 'tredecillion',
15 * 3 => 'quattuordecillion',
16 * 3 => 'quindecillion',
17 * 3 => 'sexdecillion',
18 * 3 => 'septendecillion',
19 * 3 => 'octodecillion',
20 * 3 => 'novemdecillion',
21 * 3 => 'vigintillion',
22 * 3 => 'unvigintillion',
23 * 3 => 'duovigintillion',
24 * 3 => 'trevigintillion',
25 * 3 => 'quattuorvigintillion',
26 * 3 => 'quinvigintillion',
27 * 3 => 'sexvigintillion',
28 * 3 => 'septenvigintillion',
29 * 3 => 'octovigintillion',
30 * 3 => 'novemvigintillion',
31 * 3 => 'trigintillion',
32 * 3 => 'untrigintillion',
33 * 3 => 'duotrigintillion',
100 => 'googol',
101 * 3 => 'centillion',
GOOGOL => 'googolplex'
}.freeze
- POWERS_RX =
Regexp.union(POWERS_OF_TEN.values[1..]).freeze
Class Method Summary
collapse
Class Method Details
.exceptional_number(text) ⇒ Object
36
37
38
|
# File 'lib/numbers_in_words.rb', line 36
def exceptional_number(text)
exceptional_numbers_to_i[text]
end
|
.exceptional_numbers ⇒ Object
28
29
30
|
# File 'lib/numbers_in_words.rb', line 28
def exceptional_numbers
@exceptional_numbers ||= ExceptionalNumbers.new
end
|
.in_numbers(words, only_compress: false) ⇒ Object
24
25
26
|
# File 'lib/numbers_in_words.rb', line 24
def in_numbers(words, only_compress: false)
ToNumber.new(words, only_compress).call
end
|
.in_words(num, fraction: false) ⇒ Object
20
21
22
|
# File 'lib/numbers_in_words.rb', line 20
def in_words(num, fraction: false)
ToWord.new(num).in_words(fraction: fraction)
end
|
.lookup(number) ⇒ Object
32
33
34
|
# File 'lib/numbers_in_words.rb', line 32
def lookup(number)
exceptional_numbers.lookup(number)
end
|
.power_of_ten(text) ⇒ Object
40
41
42
|
# File 'lib/numbers_in_words.rb', line 40
def power_of_ten(text)
powers_of_ten_to_i[text]
end
|