darkhelmet-darkext 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/darkext/array.rb CHANGED
@@ -29,6 +29,11 @@ class Array
29
29
  self.map(&:square)
30
30
  end
31
31
 
32
+ # Destructively collects the squares
33
+ def squares!
34
+ self.map!(&:square)
35
+ end
36
+
32
37
  # Finds the sum of squares of the array
33
38
  def sum_of_squares
34
39
  self.squares.sum
@@ -38,6 +43,7 @@ class Array
38
43
  def random
39
44
  self[rand(self.size)]
40
45
  end
46
+ alias :pick :random
41
47
 
42
48
  # Randomizes the array
43
49
  def randomize
@@ -1,3 +1,5 @@
1
+ require 'darkext/hash'
2
+
1
3
  class String
2
4
  # Parses a string like "1..10" to a Range
3
5
  def to_range
@@ -13,7 +15,12 @@ class String
13
15
  end
14
16
 
15
17
  # Executes the string with system
16
- def exec
17
- system(self)
18
+ def exec(opts = {})
19
+ opts.with_defaults!(:background => false)
20
+ cmd = self
21
+ cmd += " &" if opts[:background]
22
+ system(cmd)
18
23
  end
24
+
25
+ alias :/ :split
19
26
  end
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.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Huckstep