Sha256: 0bb654ea38f96cfc204785df918048cb133b6052572f5e1d7d1d37902ee021a5
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
module Coercible class Coercer # Base class for all numeric Coercion classes class Numeric < Object primitive ::Numeric # Coerce given value to String # # @example # coercer[Numeric].to_string(Rational(2, 2)) # => "1.0" # # @param [Numeric] value # # @return [String] # # @api public def to_string(value) value.to_s end # Creates an Integer instance from a numeric object # # @example # coercer[Numeric].to_integer(Rational(2, 2)) # => 1 # # @param [Numeric] value # # @return [Integer] # # @api public def to_integer(value) value.to_i end # 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 def to_float(value) value.to_f end end # class Numeric end # class Coercer end # module Coercible
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
motion_coercible-0.2.0 | lib/project/coercer/numeric.rb |