Class: Numeric

Inherits:
Object
  • Object
show all
Defined in:
lib/powerpack/numeric/neg.rb,
lib/powerpack/numeric/pos.rb,
lib/powerpack/numeric/scale.rb

Constant Summary

HUNDRED =
10 ** 2
THOUSAND =
10 ** 3
MILLION =
10 ** 6
BILLION =
10 ** 9
TRILLION =
10 ** 12
QUADRILLION =
10 ** 15

Instance Method Summary collapse

Instance Method Details

#billionObject



28
29
30
# File 'lib/powerpack/numeric/scale.rb', line 28

def billion
  self * BILLION
end

#hundredObject



10
11
12
# File 'lib/powerpack/numeric/scale.rb', line 10

def hundred
  self * HUNDRED
end

#millionObject



22
23
24
# File 'lib/powerpack/numeric/scale.rb', line 22

def million
  self * MILLION
end

#neg?Boolean

Checks whether a number is negative.

Examples:

5.neg? #=> false
-0.5.neg? #=> true
0.neg? #=> false

Returns:

  • (Boolean)

    true is the number is negative, false otherwise



15
16
17
# File 'lib/powerpack/numeric/neg.rb', line 15

def neg?
  self < 0
end

#pos?Boolean

Checks whether a number is positive.

Examples:

5.pos? #=> true
-0.5.pos? #=> false
0.pos? #=> false

Returns:

  • (Boolean)

    true is the number is positive, false otherwise



15
16
17
# File 'lib/powerpack/numeric/pos.rb', line 15

def pos?
  self > 0
end

#quadrillionObject



40
41
42
# File 'lib/powerpack/numeric/scale.rb', line 40

def quadrillion
  self * QUADRILLION
end

#thousandObject



16
17
18
# File 'lib/powerpack/numeric/scale.rb', line 16

def thousand
  self * THOUSAND
end

#trillionObject



34
35
36
# File 'lib/powerpack/numeric/scale.rb', line 34

def trillion
  self * TRILLION
end