Class: Necromancer::NumericConverters::StringToIntegerConverter
- Inherits:
-
Converter
- Object
- Converter
- Necromancer::NumericConverters::StringToIntegerConverter
- Defined in:
- lib/necromancer/converters/numeric.rb
Overview
An object that converts a String to an Integer
Instance Attribute Summary
Attributes inherited from Converter
#config, #convert, #source, #target
Instance Method Summary collapse
-
#call(value, strict: config.strict) ⇒ Object
Convert string value to integer.
Methods inherited from Converter
create, #initialize, #raise_conversion_type
Constructor Details
This class inherits a constructor from Necromancer::Converter
Instance Method Details
#call(value, strict: config.strict) ⇒ Object
Convert string value to integer
21 22 23 24 25 |
# File 'lib/necromancer/converters/numeric.rb', line 21 def call(value, strict: config.strict) Integer(value) rescue StandardError strict ? raise_conversion_type(value) : value.to_i end |