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

- (Object) billion



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

def billion
  self * BILLION
end

- (Object) hundred



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

def hundred
  self * HUNDRED
end

- (Object) million



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

def million
  self * MILLION
end

- (Boolean) neg?

Checks whether a number is negative.

Examples:

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


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

def neg?
  self < 0
end

- (Boolean) pos?

Checks whether a number is positive.

Examples:

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


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

def pos?
  self > 0
end

- (Object) quadrillion



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

def quadrillion
  self * QUADRILLION
end

- (Object) thousand



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

def thousand
  self * THOUSAND
end

- (Object) trillion



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

def trillion
  self * TRILLION
end