forked from radar/humanize
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
283 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module Humanize | ||
%w[az de en es fr id ms pt ru th tr jp].each do |locale| | ||
%w[az de en es fr id ms pt ru th tr jp vi].each do |locale| | ||
autoload locale.capitalize.to_sym, "humanize/locales/#{locale}.rb" | ||
end | ||
end |
Large diffs are not rendered by default.
Oops, something went wrong.
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,35 @@ | ||
require_relative 'constants/vi' | ||
|
||
module Humanize | ||
class Vi | ||
def humanize(number) | ||
iteration = 0 | ||
parts = [] | ||
until number.zero? | ||
number, remainder = number.divmod(1000) | ||
|
||
if !remainder.zero? | ||
parts << LOTS[iteration] if iteration.positive? | ||
parts << SUB_ONE_GROUPING[remainder] | ||
add_linked_word(parts, remainder) if number.positive? | ||
elsif iteration.positive? && (iteration % 3).zero? | ||
parts << LOTS[3] | ||
end | ||
|
||
iteration += 1 | ||
end | ||
|
||
parts | ||
end | ||
|
||
private | ||
|
||
def add_linked_word(parts, remainder) | ||
if remainder < 10 | ||
parts << LINKED_WORDS[0] | ||
elsif remainder < 100 | ||
parts << LINKED_WORDS[1] | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.