hash-utils 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/TODO.txt ADDED
@@ -0,0 +1,2 @@
1
+ * add examples to each call
2
+ * puts list of methods directly to readme for each class
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.6.0
data/hash-utils.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hash-utils}
8
- s.version = "0.5.0"
8
+ s.version = "0.6.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Martin Kozák"]
12
- s.date = %q{2011-02-08}
12
+ s.date = %q{2011-02-09}
13
13
  s.email = %q{martinkozak@martinkozak.net}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE.txt",
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
22
22
  "LICENSE.txt",
23
23
  "README.md",
24
24
  "Rakefile",
25
+ "TODO.txt",
25
26
  "VERSION",
26
27
  "hash-utils.gemspec",
27
28
  "lib/hash-utils.rb",
@@ -100,6 +100,64 @@ class String
100
100
  self.gsub!(matcher) { |s| defs[block.call(s)] }
101
101
  end
102
102
 
103
+ ##
104
+ # Converts String to Array of characters.
105
+ #
106
+ # @example
107
+ # foo = "012"
108
+ # puts foo.to_a.inspect # prints out ["0", "1", "2"]
109
+ #
110
+ # @return [Array] array of single character strings
111
+ # @since 0.6.0
112
+ #
113
+
114
+ def to_a
115
+ output = [ ]
116
+ self.each_char do |ch|
117
+ output << ch
118
+ end
119
+
120
+ return output
121
+ end
122
+
123
+ ##
124
+ # Applies block to each character and returns resultant string.
125
+ #
126
+ # @example
127
+ # foo = "012"
128
+ # puts foo.map { |ch| (ch.to_i + 1).to_s }.inspect # prints out "123"
129
+ #
130
+ # @param [Proc] block transforming block
131
+ # @param [String] transformed string
132
+ # @since 0.6.0
133
+ #
134
+
135
+ def map(&block)
136
+ buffer = ""
137
+ self.each_char do |ch|
138
+ buffer << block.call(ch)
139
+ end
140
+
141
+ return buffer
142
+ end
143
+
144
+ ##
145
+ # Applies block to each character in place. For example see {#map}.
146
+ # @since 0.6.0
147
+ #
148
+ # @param [Proc] block transforming block
149
+ # @return [String] self
150
+ # @see #map
151
+ #
152
+
153
+ def map!(&block)
154
+ self.length.times do |i|
155
+ self[i] = block.call(self[i])
156
+ end
157
+
158
+ self
159
+ end
160
+
103
161
 
104
162
  private
105
163
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: hash-utils
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.0
5
+ version: 0.6.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - "Martin Koz\xC3\xA1k"
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-02-08 00:00:00 +01:00
13
+ date: 2011-02-09 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -51,6 +51,7 @@ files:
51
51
  - LICENSE.txt
52
52
  - README.md
53
53
  - Rakefile
54
+ - TODO.txt
54
55
  - VERSION
55
56
  - hash-utils.gemspec
56
57
  - lib/hash-utils.rb
@@ -73,7 +74,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
74
  requirements:
74
75
  - - ">="
75
76
  - !ruby/object:Gem::Version
76
- hash: 1593935056152751223
77
+ hash: -3314318327332917166
77
78
  segments:
78
79
  - 0
79
80
  version: "0"