darkhelmet-darkext 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -11,6 +11,7 @@ test/test_helper.rb
11
11
  lib/darkext/array.rb
12
12
  lib/darkext/boolean.rb
13
13
  lib/darkext/hash.rb
14
+ lib/darkext/integer.rb
14
15
  lib/darkext/io.rb
15
16
  lib/darkext/numeric.rb
16
17
  lib/darkext/statistics.rb
@@ -0,0 +1,10 @@
1
+ require 'darkext/array'
2
+
3
+ class Integer
4
+ # Computes the factorial of the Integer
5
+ def fact
6
+ raise ArgumentError.new("Cannot compute factorial of negative number") if 0 > self
7
+ return 1 if self.zero?
8
+ return (1..self).to_a.product
9
+ end
10
+ end
@@ -6,6 +6,11 @@ class Numeric
6
6
  self * self
7
7
  end
8
8
 
9
+ # Cube the number
10
+ def cube
11
+ self.square * self
12
+ end
13
+
9
14
  # Finds the square root of the number
10
15
  def sqrt
11
16
  Math.sqrt(self)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: darkhelmet-darkext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Huckstep
@@ -55,6 +55,7 @@ files:
55
55
  - lib/darkext/array.rb
56
56
  - lib/darkext/boolean.rb
57
57
  - lib/darkext/hash.rb
58
+ - lib/darkext/integer.rb
58
59
  - lib/darkext/io.rb
59
60
  - lib/darkext/numeric.rb
60
61
  - lib/darkext/statistics.rb