active_object 5.0.1 → 5.0.2
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.
- checksums.yaml +5 -5
- data/README.md +7 -0
- data/lib/active_object/enumerable.rb +24 -0
- data/lib/active_object/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: aa463be80de37e3622d3fb6902950a690325178d54cf008352bc312c74c50941
|
4
|
+
data.tar.gz: 9c15c61ebf7cf55d878a18a46f7979667ba602472a4b6aa2476d94c0b920a694
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fe717cf374cb6c7bc5ee5397b1f9c3e89cf3dba42713368e6b4139eafe0c1589cb41469acd1e3f65a80b7aba7e9fdbbcc1b533db0cd43b12648eb16b67da593
|
7
|
+
data.tar.gz: d237263ecf3d3b69718f3b7ade775f9fe35f1270a095d5adee372b74439b101f00e3f05d7e235fca57be73f8a86107d67d4cffd30e4038755364af29eb3c0a68
|
data/README.md
CHANGED
@@ -338,6 +338,13 @@ end
|
|
338
338
|
[1, 2, 'a'].incase?(3) #=> false
|
339
339
|
```
|
340
340
|
|
341
|
+
**Interpose:**
|
342
|
+
`interpose` returns an enumerator to add seperators.
|
343
|
+
|
344
|
+
```ruby
|
345
|
+
[1, 2, 'a'].interpose(:sep).to_a #=> [1, :sep, 2, :sep, 'a']
|
346
|
+
```
|
347
|
+
|
341
348
|
**Many:**
|
342
349
|
`many?` returns if collection has more than one element while respecting nil and false as an element.
|
343
350
|
|
@@ -144,6 +144,30 @@ module Enumerable
|
|
144
144
|
end
|
145
145
|
# rubocop:enable Style/CaseEquality
|
146
146
|
|
147
|
+
def interpose(sep, &block)
|
148
|
+
enum = Enumerator.new do |val|
|
149
|
+
items = each
|
150
|
+
|
151
|
+
loop do
|
152
|
+
begin
|
153
|
+
val << items.next
|
154
|
+
rescue StopIteration
|
155
|
+
break
|
156
|
+
end
|
157
|
+
|
158
|
+
begin
|
159
|
+
items.peek
|
160
|
+
rescue StopIteration
|
161
|
+
break
|
162
|
+
else
|
163
|
+
val << sep
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
block ? enum.each(&block) : enum
|
169
|
+
end
|
170
|
+
|
147
171
|
def many?
|
148
172
|
found_count = 0
|
149
173
|
if block_given?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
170
|
rubyforge_project:
|
171
|
-
rubygems_version: 2.
|
171
|
+
rubygems_version: 2.7.2
|
172
172
|
signing_key:
|
173
173
|
specification_version: 4
|
174
174
|
summary: Gem for commonly used ruby object helpers.
|