da_huangs_ruby_extensions 0.0.17 → 0.0.18

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.17
1
+ 0.0.18
data/lib/array_ext.rb CHANGED
@@ -71,7 +71,29 @@ module DaHuang
71
71
  end
72
72
  end
73
73
  end
74
+
75
+ def map_n(&block)
76
+ return [] unless size>0
77
+ first_row = block.call(self[0])
78
+ rows = self.class.new(first_row.size, [])
79
+ first_row.each_with_index do |val, i|
80
+ rows[i] << val
81
+ end
82
+ self[1..self.size-1].each do |t|
83
+ next_row = block.call(t)
84
+ next_row.each_with_index do |val, i|
85
+ rows[i] << val
86
+ end
87
+ end
88
+ rows
89
+ end
74
90
  end
75
91
 
76
92
  end
77
93
 
94
+ Array.send :include, DaHuang::ArrayExt
95
+
96
+ [1,2,3,4].map_n do |t|
97
+ [t, 1, t*9]
98
+ end
99
+
@@ -14,3 +14,5 @@ String.send :include, DaHuang::StringExt
14
14
  require 'object_ext'
15
15
  Object.send :include, DaHuang::ObjectExt
16
16
 
17
+ require 'integer_ext'
18
+
@@ -0,0 +1,10 @@
1
+ module DaHuang
2
+ module IntegerExtensions
3
+ def inspect
4
+ to_s
5
+ end
6
+ end
7
+ end
8
+
9
+ Integer.send :include, DaHuang::IntegerExtensions
10
+
data/lib/string_ext.rb CHANGED
@@ -17,6 +17,10 @@ module DaHuang
17
17
  titleize.gsub(" ", "_")
18
18
  end
19
19
 
20
+ def inspect
21
+ "'" + to_s + "'"
22
+ end
23
+
20
24
  # Convert a string to a format suitable for a URL without ever using escaped characters.
21
25
  # It calls strip, removeaccents, downcase (optional) then removes the spaces (optional)
22
26
  # and finally removes any characters matching the default regexp (/[^-_A-Za-z0-9]/).
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: da_huangs_ruby_extensions
3
3
  version: !ruby/object:Gem::Version
4
- hash: 61
4
+ hash: 59
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 17
10
- version: 0.0.17
9
+ - 18
10
+ version: 0.0.18
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tyler Gannon
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-07 00:00:00 -07:00
18
+ date: 2010-08-17 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -50,6 +50,7 @@ files:
50
50
  - lib/array_ext.rb
51
51
  - lib/da_huangs_ruby_extensions.rb
52
52
  - lib/hash_ext.rb
53
+ - lib/integer_ext.rb
53
54
  - lib/nil_class_ext.rb
54
55
  - lib/object_ext.rb
55
56
  - lib/string_ext.rb