-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#54. Support fractional form for Ukranian.
- Loading branch information
Showing
10 changed files
with
126 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
lib/numbers_and_words/strategies/figures_converter/decorators/ua.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require 'numbers_and_words/strategies/figures_converter/decorators/ua/base' | ||
require 'numbers_and_words/strategies/figures_converter/decorators/ua/fractional' | ||
require 'numbers_and_words/strategies/figures_converter/decorators/ua/integral' |
12 changes: 12 additions & 0 deletions
12
lib/numbers_and_words/strategies/figures_converter/decorators/ua/base.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module NumbersAndWords | ||
module Strategies | ||
module FiguresConverter | ||
module Decorators | ||
module Ua | ||
class Base < Decorators::Base | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
39 changes: 39 additions & 0 deletions
39
lib/numbers_and_words/strategies/figures_converter/decorators/ua/fractional.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module NumbersAndWords | ||
module Strategies | ||
module FiguresConverter | ||
module Decorators | ||
module Ua | ||
class Fractional < Base | ||
|
||
def run | ||
@options[:gender] = :female | ||
"#{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| 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 |
27 changes: 27 additions & 0 deletions
27
lib/numbers_and_words/strategies/figures_converter/decorators/ua/integral.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module NumbersAndWords | ||
module Strategies | ||
module FiguresConverter | ||
module Decorators | ||
module Ua | ||
class Integral < Base | ||
|
||
def run | ||
@options[:gender] = :female | ||
"#{super} #{integral_significance}" | ||
end | ||
|
||
private | ||
|
||
def integral_significance | ||
@strategy.translations.integral figures.reverse.join.to_i | ||
end | ||
|
||
def figures | ||
@strategy.language.figures | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
to_words: | ||
fractions: | ||
0.1: нуль цiлих i одна десята | ||
0.7: нуль цiлих i сiм десятих | ||
0.01: нуль цiлих i одна сота | ||
0.77: нуль цiлих i сiмдесят сiм сотих | ||
0.777: нуль цiлих i сiмсот сiмдесят сiм тисячних | ||
0.7777: нуль цiлих i сiм тисяч сiмсот сiмдесят сiм десяти тисячних | ||
0.77777: нуль цiлих i сiмдесят сiм тисяч сiмсот сiмдесят сiм сто тисячних | ||
0.777777: нуль цiлих i сiмсот сiмдесят сiм тисяч сiмсот сiмдесят сiм мiльйонних | ||
0.7777777: нуль цiлих i сiм мiльйонiв сiмсот сiмдесят сiм тисяч сiмсот сiмдесят сiм десяти мiльйонних | ||
0.77777777: нуль цiлих i сiмдесят сiм мiльйонiв сiмсот сiмдесят сiм тисяч сiмсот сiмдесят сiм сто мiльйонних | ||
0.777777777: нуль цiлих i сiмсот сiмдесят сiм мiльйонiв сiмсот сiмдесят сiм тисяч сiмсот сiмдесят сiм мiльярдних | ||
0.2935174315119: нуль цiлих i два трильйона дев’ятсот тридцять п’ять мiльярдiв сто сiмдесят чотири мiльйона триста п’ятнадцять тисяч сто дев’ятнадцять десяти трильйонних | ||
21.77: двадцять одна цiла i сiмдесят сiм сотих | ||
111.999: сто одинадцять цiлих i дев’ятсот дев’яносто дев’ять тисячних | ||
4242.7463: чотири тисячi двiстi сорок двi цiлих i сiм тисяч чотириста шiстдесят три десяти тисячних |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters