Class Index [+]

Quicksearch

DataMapper::Property::Typecast::Numeric

Public Instance Methods

typecast_to_numeric(value, method) click to toggle source

Match numeric string

@param [#, Numeric] value

  value to typecast

@param [Symbol] method

  method to typecast with

@return [Numeric]

  number if matched, value if no match

@api private

    # File lib/dm-core/property/typecast/numeric.rb, line 16
16:         def typecast_to_numeric(value, method)
17:           if value.respond_to?(:to_str)
18:             if value.to_str =~ /\A(-?(?:0|[1-9]\d*)(?:\.\d+)?|(?:\.\d+))\z/
19:               $1.send(method)
20:             else
21:               value
22:             end
23:           elsif value.respond_to?(method)
24:             value.send(method)
25:           else
26:             value
27:           end
28:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.