/
fractional.rb
38 lines (31 loc) · 877 Bytes
/
fractional.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module NumbersAndWords
module Strategies
module FiguresConverter
module Decorators
module Hu
class Fractional < Base
def run
"#{super} #{fraction_significance}"
end
private
def fraction_significance
@strategy.translations.micros full_fraction.fraction_capacity, figures.reverse.join.to_i
end
def full_fraction
(0..zero_length).inject(figures.clone) { |result, el| result.unshift '0' }.to_figures
end
def figures
@strategy.figures
end
def zero_length
fraction_length - figures.length
end
def fraction_length
@options[:fractional][:length].to_i
end
end
end
end
end
end
end