module Money::Constructors
Public Instance Methods
ca_dollar(cents)
click to toggle source
Creates a new Money
object of the given value, using the Canadian dollar currency.
@param [Integer] cents The cents value.
@return [Money]
@example
n = Money.ca_dollar(100) n.cents #=> 100 n.currency #=> #<Money::Currency id: cad>
# File lib/money/money/constructors.rb, line 29 def ca_dollar(cents) new(cents, "CAD") end
Also aliased as: cad
empty(currency = default_currency)
click to toggle source
Create a new money object with value 0.
@param [Currency, String, Symbol] currency The currency to use.
@return [Money]
@example
Money.empty #=> #<Money @fractional=0>
# File lib/money/money/constructors.rb, line 12 def empty(currency = default_currency) new(0, currency) end
Also aliased as: zero
euro(cents)
click to toggle source
Creates a new Money
object of the given value, using the Euro currency.
@param [Integer] cents The cents value.
@return [Money]
@example
n = Money.euro(100) n.cents #=> 100 n.currency #=> #<Money::Currency id: eur>
# File lib/money/money/constructors.rb, line 62 def euro(cents) new(cents, "EUR") end
Also aliased as: eur
pound_sterling(pence)
click to toggle source
Creates a new Money
object of the given value, in British pounds.
@param [Integer] pence The pence value.
@return [Money]
@example
n = Money.pound_sterling(100) n.fractional #=> 100 n.currency #=> #<Money::Currency id: gbp>
# File lib/money/money/constructors.rb, line 78 def pound_sterling(pence) new(pence, "GBP") end
Also aliased as: gbp
us_dollar(cents)
click to toggle source
Creates a new Money
object of the given value, using the American dollar currency.
@param [Integer] cents The cents value.
@return [Money]
@example
n = Money.us_dollar(100) n.cents #=> 100 n.currency #=> #<Money::Currency id: usd>
# File lib/money/money/constructors.rb, line 46 def us_dollar(cents) new(cents, "USD") end
Also aliased as: usd