-
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.
Merge remote-tracking branch 'remotes/origin/feature/ordinals' into feature/ordinals
- Loading branch information
Showing
22 changed files
with
359 additions
and
56 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
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
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
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: 2 additions & 1 deletion
3
lib/numbers_and_words/strategies/figures_converter/options/en.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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
require 'numbers_and_words/strategies/figures_converter/options/en/hundreds_with_union' | ||
require 'numbers_and_words/strategies/figures_converter/options/en/remove_hyphen' | ||
require 'numbers_and_words/strategies/figures_converter/options/en/remove_hyphen' | ||
require 'numbers_and_words/strategies/figures_converter/options/en/ordinal' |
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,67 @@ | ||
module NumbersAndWords | ||
module Strategies | ||
module FiguresConverter | ||
module Options | ||
module En | ||
class Ordinal | ||
HUNDRED_TYPE = :hundreds | ||
MEGS_TYPE = :megs | ||
|
||
attr_accessor :strategy, :options | ||
|
||
def initialize proxy, *args, &block | ||
@strategy = proxy.strategy | ||
@options = proxy.options | ||
end | ||
|
||
def result type, proc_method, proc_options = {} | ||
@type, @proc_method, @proc_options = type, proc_method, proc_options | ||
MEGS_TYPE != type ? check_simple_numbers : check_megs_numbers | ||
end | ||
|
||
private | ||
|
||
def active? | ||
@options[:ordinal] | ||
end | ||
|
||
def check_simple_numbers | ||
@proc_options[:prefix] = :ordinal if simple_numbers_condition && active? | ||
@proc_method.call figures.send(@type), @proc_options | ||
end | ||
|
||
def check_megs_numbers | ||
@proc_options[:prefix] = :ordinal if megs_numbers_condition && active? | ||
@proc_method.call current_capacity, nil, @proc_options | ||
end | ||
|
||
def simple_numbers_condition | ||
current_capacity.nil? && | ||
(HUNDRED_TYPE != @type || (HUNDRED_TYPE == @type && simple_number_to_words.empty?)) | ||
end | ||
|
||
def megs_numbers_condition | ||
current_capacity == language_figures.ordinal_capacity | ||
end | ||
|
||
def simple_number_to_words | ||
strategy.language.simple_number_to_words | ||
end | ||
|
||
def current_capacity | ||
strategy.language.current_capacity | ||
end | ||
|
||
def language_figures | ||
strategy.language.parent_figures | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'numbers_and_words/strategies/figures_converter/options/hu/ordinal' |
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,67 @@ | ||
module NumbersAndWords | ||
module Strategies | ||
module FiguresConverter | ||
module Options | ||
module Hu | ||
class Ordinal | ||
HUNDRED_TYPE = :hundreds | ||
MEGS_TYPE = :megs | ||
|
||
attr_accessor :strategy, :options | ||
|
||
def initialize proxy, *args, &block | ||
@strategy = proxy.strategy | ||
@options = proxy.options | ||
end | ||
|
||
def result type, proc_method, proc_options = {} | ||
@type, @proc_method, @proc_options = type, proc_method, proc_options | ||
MEGS_TYPE != type ? check_simple_numbers : check_megs_numbers | ||
end | ||
|
||
private | ||
|
||
def active? | ||
@options[:ordinal] | ||
end | ||
|
||
def check_simple_numbers | ||
@proc_options[:prefix] = :ordinal if simple_numbers_condition && active? | ||
@proc_method.call figures.send(@type), @proc_options | ||
end | ||
|
||
def check_megs_numbers | ||
@proc_options[:prefix] = :ordinal if megs_numbers_condition && active? | ||
@proc_method.call current_capacity, nil, @proc_options | ||
end | ||
|
||
def simple_numbers_condition | ||
current_capacity.nil? && | ||
(HUNDRED_TYPE != @type || (HUNDRED_TYPE == @type && simple_number_to_words.empty?)) | ||
end | ||
|
||
def megs_numbers_condition | ||
current_capacity == language_figures.ordinal_capacity | ||
end | ||
|
||
def simple_number_to_words | ||
strategy.language.simple_number_to_words | ||
end | ||
|
||
def current_capacity | ||
strategy.language.current_capacity | ||
end | ||
|
||
def language_figures | ||
strategy.language.parent_figures | ||
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
Oops, something went wrong.