Class: Numeric
Instance Method Summary collapse
-
#cube ⇒ Object
Cube the number.
-
#ln ⇒ Object
Finds the log base e of the number.
-
#log ⇒ Object
Finds the log base 10 of the number.
-
#root(n = 2) ⇒ Object
Do some other roots.
-
#sqrt ⇒ Object
Finds the square root of the number.
-
#square ⇒ Object
Squares the number.
Instance Method Details
#cube ⇒ Object
Cube the number
10 11 12 |
# File 'lib/darkext/numeric.rb', line 10 def cube self.square * self end |
#ln ⇒ Object
Finds the log base e of the number
27 28 29 |
# File 'lib/darkext/numeric.rb', line 27 def ln Math::log(self) end |
#log ⇒ Object
Finds the log base 10 of the number
32 33 34 |
# File 'lib/darkext/numeric.rb', line 32 def log Math::log10(self) end |
#root(n = 2) ⇒ Object
Do some other roots
20 21 22 23 24 |
# File 'lib/darkext/numeric.rb', line 20 def root(n = 2) return self if 1 == n return self.sqrt if 2 == n self ** (1 / n.to_f) end |
#sqrt ⇒ Object
Finds the square root of the number
15 16 17 |
# File 'lib/darkext/numeric.rb', line 15 def sqrt Math.sqrt(self) end |
#square ⇒ Object
Squares the number
5 6 7 |
# File 'lib/darkext/numeric.rb', line 5 def square self * self end |