Class: Numeric

Inherits:
Object show all
Includes:
Comparable
Defined in:
lib/framework/builtinME.rb

Direct Known Subclasses

Date::Infinity, Integer, NumericMockObject, Rational

Instance Method Summary collapse

Methods included from Comparable

#<, #<=, #==, #>, #>=, #between?

Instance Method Details

#absObject



486
487
488
489
# File 'lib/framework/builtinME.rb', line 486

def abs
    return -self if (self <=> 0) == -1
    self
end

#div(value) ⇒ Object



491
492
493
# File 'lib/framework/builtinME.rb', line 491

def div value
    (self/value).floor
end

#divmod(value) ⇒ Object



495
496
497
# File 'lib/framework/builtinME.rb', line 495

def divmod(value)
    [(self/value).floor, self % value]
end

#floorObject



482
483
484
# File 'lib/framework/builtinME.rb', line 482

def floor
    self.to_f.floor
end

#integer?Boolean

Returns:

  • (Boolean)


499
500
501
# File 'lib/framework/builtinME.rb', line 499

def integer?
    false
end

#modulo(value) ⇒ Object



505
506
507
# File 'lib/framework/builtinME.rb', line 505

def modulo(value)
    self % value
end

#nonzero?Boolean

Returns:

  • (Boolean)


509
510
511
512
# File 'lib/framework/builtinME.rb', line 509

def nonzero?
    return nil if self == 0
    self
end

#remainder(value) ⇒ Object



519
520
521
522
523
524
# File 'lib/framework/builtinME.rb', line 519

def remainder(value)
    self_sign = (self < 0)
    value_sign = (value < 0)
    return self % value if self_sign == value_sign
    self % (-value)
end

#zero?Boolean

Returns:

  • (Boolean)


514
515
516
517
# File 'lib/framework/builtinME.rb', line 514

def zero?
    return true if self == 0
    false
end