Method: Code::Object::Integer#initialize

Defined in:
lib/code/object/integer.rb

#initialize(*args, **_kargs) ⇒ Integer

Returns a new instance of Integer.



6
7
8
9
10
11
12
13
14
# File 'lib/code/object/integer.rb', line 6

def initialize(*args, **_kargs, &)
  whole = args.first || 0
  exponent = args.second || 0
  whole = whole.raw if whole.is_an?(Object)
  exponent = exponent.raw if exponent.is_an?(Object)
  @raw = whole.to_i * (10**exponent)
rescue FloatDomainError
  raise Error, "#{decimal.inspect} * 10**#{exponent.inspect} is invalid"
end