Skip to content

Commit

Permalink
Add special case for one thousand in spanish
Browse files Browse the repository at this point in the history
  • Loading branch information
jlduran committed Oct 21, 2013
1 parent f9712d9 commit 3ee433c
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions lib/numbers_and_words/strategies/figures_converter/languages/es.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,27 @@ def capacity_iteration
words.push megs(capacity_words) unless capacity_words.empty?

if 0 < @current_capacity
# eg 1000000 should be "un millon" not "uno millon"
# eg 1000000 should be "un millón" not "uno millón"
# 501000 should be "quinientos un mil" not "quinientos uno mil"
# so we replace "uno" with "un" throughout
# 1000 should be "mil" not "uno mil"
# so we replace "uno" with "un" throughout or delete it if that is the case

capacity_words = capacity_words.map{|word|
word.gsub( @translations.ones(1), @translations.one )
}
capacity_words = capacity_words.map { |word|
word.gsub(@translations.ones(1), @translations.one) unless is_a_thousand? and is_a_one?
}.compact
end

words + capacity_words
end

def is_a_one?
[translations.ones(1)] == words_in_capacity(@current_capacity)
end

def is_a_thousand?
FiguresArray::THOUSAND_CAPACITY == @current_capacity
end

def hundreds
super({:is_hundred => (figures[1,2] == [0,1] && simple_number_to_words.empty?)})
end
Expand Down

0 comments on commit 3ee433c

Please sign in to comment.