darkhelmet-darkext 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,24 +1,41 @@
1
- = darkext
2
-
3
- * http://github.com/darkhelmet/darkext/
1
+ = darkext[http://github.com/darkhelmet/darkext/]
4
2
 
5
3
  == DESCRIPTION:
6
4
 
7
5
  Just some useful Ruby functionality. No particular focus, except usefulness
8
6
 
9
- == FEATURES/PROBLEMS:
10
-
11
- * FIX (list of features or problems)
12
-
13
- == SYNOPSIS:
14
-
15
- FIX (code sample of usage)
16
-
17
- == REQUIREMENTS:
18
-
19
- * FIX (list of requirements)
20
-
21
- == INSTALL:
7
+ == FEATURES:
8
+
9
+ * Adds to Array
10
+ * rotate, rotate_reverse
11
+ * sum, product
12
+ * squares, squares!
13
+ * random, randomize, randomize!
14
+ * Adds to TrueClass and FalseClass
15
+ * intern
16
+ * Adds to Hash
17
+ * with_defaults, with_defaults!
18
+ * Adds to Integer
19
+ * fact
20
+ * Adds to Numeric
21
+ * square, cube
22
+ * sqrt
23
+ * ln, log
24
+ * Adds to Object
25
+ * try
26
+ * is_boolean?
27
+ * Adds to String
28
+ * to_range
29
+ * exec
30
+ * print
31
+ * Adds IO package
32
+ * Adds statistical package
33
+
34
+ == USAGE:
35
+
36
+ $ require 'darkext'
37
+
38
+ == INSTALLATION:
22
39
 
23
40
  * $ gem sources -a http://gems.github.com # unless you already have done this
24
41
  * $ gem install darkhelmet-darkext
data/lib/darkext/array.rb CHANGED
@@ -34,11 +34,6 @@ class Array
34
34
  self.map!(&:square)
35
35
  end
36
36
 
37
- # Finds the sum of squares of the array
38
- def sum_of_squares
39
- self.squares.sum
40
- end
41
-
42
37
  # Picks a random value from the array
43
38
  def random
44
39
  self[rand(self.size)]
@@ -1,3 +1,9 @@
1
+ class Object
2
+ def is_boolean?
3
+ self.is_a?(TrueClass) || self.is_a?(FalseClass)
4
+ end
5
+ end
6
+
1
7
  class TrueClass
2
8
  def intern
3
9
  return :true
@@ -15,4 +15,14 @@ class Numeric
15
15
  def sqrt
16
16
  Math.sqrt(self)
17
17
  end
18
+
19
+ # Finds the log base e of the number
20
+ def ln
21
+ Math::log(self)
22
+ end
23
+
24
+ # Finds the log base 10 of the number
25
+ def log
26
+ Math::log10(self)
27
+ end
18
28
  end
@@ -95,15 +95,15 @@ class Array
95
95
 
96
96
  def sum_of_squares
97
97
  m = self.mean
98
- self.map { |v| v - m }.map(&:square).sum
98
+ self.map { |v| v - m }.squares.sum
99
99
  end
100
100
 
101
- # Normalize the Array
101
+ # Normalize the array
102
102
  def normalize
103
103
  self.clone.normalize!
104
104
  end
105
105
 
106
- # Normalize the Array destructive
106
+ # Normalize the array destructively
107
107
  def normalize!
108
108
  m = self.mean.to_f
109
109
  self.map! { |v| v / m }
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.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Huckstep
@@ -61,7 +61,7 @@ files:
61
61
  - lib/darkext/string.rb
62
62
  - lib/darkext/symbol.rb
63
63
  has_rdoc: true
64
- homepage: http://github.com/darkhelmet/darkext/
64
+ homepage:
65
65
  post_install_message: PostInstall.txt
66
66
  rdoc_options:
67
67
  - --main