Class: CurrencyInWords::FrTexterizer
- Inherits:
-
Object
- Object
- CurrencyInWords::FrTexterizer
- Defined in:
- lib/currency-in-words.rb
Overview
:nodoc: all This is the strategy class for French language
Instance Method Summary collapse
Instance Method Details
#texterize(context) ⇒ Object
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/currency-in-words.rb', line 223 def texterize context int_part, dec_part = context.number_parts connector = context.[:connector] int_unit_one = context.[:currency][:unit][:one] int_unit_many = context.[:currency][:unit][:many] int_unit_more = context.[:currency][:unit][:more] dec_unit_one = context.[:currency][:decimal][:one] dec_unit_many = context.[:currency][:decimal][:many] unless int_unit_many int_unit_many = int_unit_one+'s' end unless int_unit_more int_unit_more = if int_unit_many.start_with?("a","e","i","o","u") "d'"+int_unit_many else "de "+int_unit_many end end unless dec_unit_many dec_unit_many = dec_unit_one+'s' end int_unit = if int_part > 1 (int_part % 10**6).zero? ? int_unit_more : int_unit_many else int_unit_one end dec_unit = dec_part > 1 ? dec_unit_many : dec_unit_one feminize = context.[:currency][:unit][:feminine] || false texterized_int_part = (texterize_by_group(int_part, 0, feminize).compact << int_unit).flatten.join(' ') feminize = context.[:currency][:decimal][:feminine] || false texterized_dec_part = (texterize_by_group(dec_part, 0, feminize).compact << dec_unit).flatten.join(' ') if dec_part.zero? texterized_int_part else texterized_int_part << connector << texterized_dec_part end end |