Class: Parameters::Types::Integer Private

Inherits:
Object show all
Defined in:
lib/parameters/types/integer.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.3.0

Class Method Summary collapse

Methods inherited from Object

#===, ===, to_ruby

Methods inherited from Type

#<, #<=, #==, ===, #===, #coerce, #to_ruby, to_ruby

Class Method Details

.coerce(value) ⇒ ::Integer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Coerces a value into an Integer.

Parameters:

  • value (::String, #to_i)

    The value to coerce.

Returns:

  • (::Integer)

    The coerced Integer.

Since:

  • 0.3.0



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/parameters/types/integer.rb', line 16

def self.coerce(value)
  case value
  when ::String
    value.to_i(0)
  else
    if value.respond_to?(:to_i)
      value.to_i
    else
      0
    end
  end
end