module Polyfill::V2_6::Kernel

Public Instance Methods

Complex(*args, exception: true) click to toggle source
Calls superclass method
# File lib/polyfill/v2_6/kernel.rb, line 6
def Complex(*args, exception: true) # rubocop:disable Naming/MethodName
  super(*args) if exception

  x, y = *args
  if !x.nil? && !x.is_a?(::String) && !x.is_a?(::Numeric) && !y.nil? && y.is_a?(::Numeric)
    raise ::TypeError, 'not a real'
  end

  begin
    super(*args)
  rescue ::ArgumentError, ::TypeError
    nil
  end
end
Float(arg, exception: true) click to toggle source
Calls superclass method
# File lib/polyfill/v2_6/kernel.rb, line 21
def Float(arg, exception: true) # rubocop:disable Naming/MethodName
  super(arg) if exception

  begin
    super(arg)
  rescue ::ArgumentError, ::TypeError
    nil
  end
end
Integer(arg, exception: true) click to toggle source
Calls superclass method
# File lib/polyfill/v2_6/kernel.rb, line 31
def Integer(arg, exception: true) # rubocop:disable Naming/MethodName
  super(arg) if exception

  begin
    super(arg)
  rescue ::ArgumentError, ::TypeError, ::FloatDomainError
    nil
  end
end
Rational(*args, exception: true) click to toggle source
Calls superclass method
# File lib/polyfill/v2_6/kernel.rb, line 41
def Rational(*args, exception: true) # rubocop:disable Naming/MethodName
  super(*args) if exception

  begin
    super(*args)
  rescue ::ArgumentError, ::TypeError
    nil
  end
end
then() click to toggle source
# File lib/polyfill/v2_6/kernel.rb, line 51
def then
  return yield_self unless block_given?

  yield_self(&::Proc.new)
end