Class: String Private

Inherits:
Object
  • Object
show all
Defined in:
lib/money_attribute/core_ext/string.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Convenience method for parsing Mint::Money from strings.

Instance Method Summary collapse

Instance Method Details

#to_money(currency = MoneyAttribute.default_currency) ⇒ Mint::Money

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parses the string into a Mint::Money value.

Examples:

'12.34'.to_money('USD') # => Mint::Money(12.34, 'USD')

Parameters:

Returns:

  • (Mint::Money)

Raises:

  • (ArgumentError)

    if the string cannot be parsed



17
# File 'lib/money_attribute/core_ext/string.rb', line 17

def to_money(currency = MoneyAttribute.default_currency) = Money.parse(self, currency)