lib/money_helper.rb in money_helper-3.0.1 vs lib/money_helper.rb in money_helper-3.0.2

- old
+ new

@@ -69,21 +69,24 @@ # low: (Integer) amount in minor unit # high: (Integer) amount in minor unit # currency: (String) optional ISO currency code, defaulting to USD # delimiter: (String) optional # with_currency: (Boolean) optional flag to include ISO currency code, defaulting to true - def self.money_range_to_text(low, high, currency: 'USD', delimiter: ' - ', with_currency: true) + #  format: (Hash) optional formatting options to pass to `Money#format` e.g.: + # no_cents: (Boolean) optional flag to exclude cents, defaulting to false + # symbol: (Boolean) optional flag to include currency symbol, defaulting to true + def self.money_range_to_text(low, high, currency: 'USD', delimiter: ' - ', with_currency: true, format: {}) if low.blank? && high.blank? '' elsif low.blank? - "Under #{money_to_text(high, currency: currency, with_currency: with_currency)}" + "Under #{money_to_text(high, currency: currency, with_currency: with_currency, format: format)}" elsif high.blank? - "#{money_to_text(low, currency: currency, with_currency: with_currency)} and up" + "#{money_to_text(low, currency: currency, with_currency: with_currency, format: format)} and up" elsif low == high - money_to_text(low, currency: currency, with_currency: with_currency) + money_to_text(low, currency: currency, with_currency: with_currency, format: format) else - formatted_low = money_to_text(low, currency: currency, with_currency: with_currency) - formatted_high = money_to_text(high, currency: currency, with_currency: false, format: { symbol: false }) + formatted_low = money_to_text(low, currency: currency, with_currency: with_currency, format: format) + formatted_high = money_to_text(high, currency: currency, with_currency: false, format: { symbol: false }.merge(format)) [formatted_low, formatted_high].compact.join(delimiter) end end def self.code_valid?(code)