struct
Money::Currency::Rate
- Money::Currency::Rate
- Struct
- Value
- Object
Included Modules
- Comparable(Money::Currency::Rate)
- JSON::Serializable
Defined in:
money/currency/json.crmoney/currency/rate.cr
Constructors
- .new(from : Currency, to : Currency, value : BigDecimal, updated_at : Time = Time.utc)
- .new(pull : JSON::PullParser)
Instance Method Summary
-
#<=>(other : Rate) : Int32
The comparison operator.
- #clone
- #copy_with(from _from = @from, to _to = @to, value _value = @value, updated_at _updated_at = @updated_at)
- #from : Currency
- #to : Currency
- #to_json(json : JSON::Builder)
- #to_s(io : IO, *, include_updated_at = false) : Nil
- #to_s(*, include_updated_at = false) : String
- #updated_at : Time
- #value : BigDecimal
Constructor Detail
Instance Method Detail
Description copied from module Comparable(Money::Currency::Rate)
The comparison operator. Returns 0
if the two objects are equal,
a negative number if this object is considered less than other,
a positive number if this object is considered greater than other,
or nil
if the two objects are not comparable.
Subclasses define this method to provide class-specific ordering.
The comparison operator is usually used to sort values:
# Sort in a descending way:
[3, 1, 2].sort { |x, y| y <=> x } # => [3, 2, 1]
# Sort in an ascending way:
[3, 1, 2].sort { |x, y| x <=> y } # => [1, 2, 3]
def copy_with(from _from = @from, to _to = @to, value _value = @value, updated_at _updated_at = @updated_at)
#