Module: Xqsr3::Conversion::IntegerParser
- Defined in:
- lib/xqsr3/conversion/integer_parser.rb
Overview
+include-able module that provides Integer parsing
Class Method Summary collapse
-
.to_integer(arg, base = 0, **options, &block) ⇒ Object
Attempts to convert a variable to an integer, according to the given options and block.
Instance Method Summary collapse
-
#to_integer(base = 0, **options, &block) ⇒ Object
Instance form of ::Xqsr3::Conversion::IntegerParser.to_integer.
Class Method Details
.to_integer(arg, base = 0, **options, &block) ⇒ Object
Attempts to convert a variable to an integer, according to the given options and block
Signature
-
Parameters:
-
arg
The argument to be converted (toFixnum
orBignum
); -
base
A value of 0, or between 2 and 36. Defaults to 0; -
options
(Hash
) Options that control the behaviour of the method; -
block
An optional caller-supplied 4-parameter block - taking the exception,arg
,base
, andoptions
- that will be invoked with theArgumentError
exception, allowing the caller to take additional action. If the block returns then its return value will be returned to the caller;
-
-
Options:
-
:default
A default value to be used whenarg
isnil
or cannot be converted by (the original) Kernel#Integer; -
:nil
Returnsnil
ifarg
isnil
or cannot be converted by (the original) Kernel#Integer. Ignored if:default
is specified;
-
166 167 168 169 |
# File 'lib/xqsr3/conversion/integer_parser.rb', line 166 def self.to_integer arg, base = 0, **, &block IntegerParser_Helper_.to_integer_ arg, base, , &block end |
Instance Method Details
#to_integer(base = 0, **options, &block) ⇒ Object
Instance form of ::Xqsr3::Conversion::IntegerParser.to_integer
172 173 174 175 |
# File 'lib/xqsr3/conversion/integer_parser.rb', line 172 def to_integer base = 0, **, &block IntegerParser_Helper_.to_integer_ self, base, , &block end |