Module: Kernel

Defined in:
lib/xqsr3/extensions/kernel/integer.rb,
lib/xqsr3/extensions/kernel/raise_with_options.rb

Instance Method Summary collapse

Instance Method Details

#Integer(arg, base = 0, **options) ⇒ Object

A monkey-patch extension of Kernel#Integer with options

Signature

  • Parameters:

    • arg

      The argument to be converted (to Fixnum or Bignum)

    • base

      A value of 0, or between 2 and 36. Defaults to 0

    • options

      An options hash, containing any of the following

    options

  • Options:

    • :default

      A default value to be used when arg is nil or

      cannot be converted by (the original) Kernel#Integer

    • :nil

      Returns nil if arg is nil or cannot be

      converted by (the original) Kernel#Integer. Ignored if :default is specified



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/xqsr3/extensions/kernel/integer.rb', line 73

def Integer(arg, base = 0, **options)

	if options.has_key?(:default) || options[:nil]

		unless arg.nil?

			begin

				return xqsr3_Integer_original_method arg, base
			rescue ArgumentError
			end
		end

		return options[:default] if options.has_key? :default

		return nil
	else

		xqsr3_Integer_original_method arg, base
	end
end

#raise_with_options(*args, **options) ⇒ Object

Extends Kernel module with the ::Xqsr3::Diagnostics::ExceptionUtilities::raise_with_options method



59
60
61
62
63
64
# File 'lib/xqsr3/extensions/kernel/raise_with_options.rb', line 59

def raise_with_options *args, **options

	options	||=	{}

	::Xqsr3::Diagnostics::ExceptionUtilities.raise_with_options(*args, **(options.merge({ :called_indirectly_06d353cb_5a6c_47ca_8dbe_ff76359c7e96 => 1})))
end