Class Coercible::Coercer::Numeric
In: lib/coercible/coercer/numeric.rb
Parent: Object

Base class for all numeric Coercion classes

Methods

Public Instance methods

Coerce a BigDecimal instance from a numeric object

@example

  coercer[Numeric].to_decimal(Rational(2, 2))  # => BigDecimal('1.0')

@param [Numeric] value

@return [BigDecimal]

@api public

Creates a Float instance from a numeric object

@example

  coercer[Numeric].to_float(Rational(2, 2))  # => 1.0

@param [Numeric] value

@return [Float]

@api public

Creates an Integer instance from a numeric object

@example

  coercer[Numeric].to_integer(Rational(2, 2))  # => 1

@param [Numeric] value

@return [Integer]

@api public

Coerce given value to String

@example

  coercer[Numeric].to_string(Rational(2, 2))  # => "1.0"

@param [Numeric] value

@return [String]

@api public

[Validate]