with_ease 0.0.1 → 0.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 +4 -4
- data/README.md +5 -0
- data/lib/with_ease/all.rb +14 -0
- data/lib/with_ease/array_to_proc.rb +8 -0
- data/lib/with_ease/constructor_functions.rb +10 -0
- data/lib/with_ease/iterator.rb +19 -2
- data/lib/with_ease/version.rb +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1acaa86f823eeec13d846b6af27f39e94ec5bffa9d19fa81ce78994680efbfa5
|
4
|
+
data.tar.gz: 2c23c88589ed075d3289e27528e9d8ceb1acda6eeee0a45e6c21cae6a95240ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6cb7b523b7481b4696242a2addd533cd08c158f6652e8e8ab11b2aa6cbeb262abfbde383a14ad51e3dda8013ff45ba431901fdcd075636aaf48d73c10aac6f8
|
7
|
+
data.tar.gz: 2f5c8b59bf12285100c0cabf7a592a55117a8b6c0e0e9d946141d14c76290c24c2770a8bc519210ac4b58cf3bf7c5b45a73292d570aec7e6f79d97a87f46937e
|
data/README.md
CHANGED
@@ -51,6 +51,11 @@ Nothing you cannot do with `Enumerator::Lazy` but so much simpler again.
|
|
51
51
|
|
52
52
|
[c.f for details](speculations/iterator.md)
|
53
53
|
|
54
|
+
#### Extend the `&:<method>` cludge from symbols to arrays with `Array#.to_proc`
|
55
|
+
|
56
|
+
My philosophy on this, is either use both or hate both
|
57
|
+
|
58
|
+
[c.f for details](speculations/array_to_proc.md)
|
54
59
|
|
55
60
|
## Quick Start
|
56
61
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'array_to_proc'
|
4
|
+
require_relative 'closed_struct'
|
5
|
+
require_relative 'forward'
|
6
|
+
require_relative 'iterator'
|
7
|
+
require_relative 'open_struct'
|
8
|
+
|
9
|
+
ClosedStruct = WithEase::ClosedStruct
|
10
|
+
Forward = WithEase::Forward
|
11
|
+
Iterator = WithEase::Iterator
|
12
|
+
|
13
|
+
require_relative 'constructor_functions'
|
14
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'closed_struct'
|
4
|
+
require_relative 'iterator'
|
5
|
+
require_relative 'open_struct'
|
6
|
+
|
7
|
+
def ClosedStruct(**k) = WithEase::ClosedStruct.new(**k)
|
8
|
+
def Iterator(init, &blk) = WithEase::Iterator.new(init, &blk)
|
9
|
+
def OpenStruct(**k) = WithEase::OpenStruct.new(**k)
|
10
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
data/lib/with_ease/iterator.rb
CHANGED
@@ -6,7 +6,10 @@ module WithEase
|
|
6
6
|
|
7
7
|
attr_reader :advancer, :value
|
8
8
|
|
9
|
-
def advance = drop
|
9
|
+
def advance = drop
|
10
|
+
def advance_fn = -> { drop }
|
11
|
+
|
12
|
+
def call = advance
|
10
13
|
|
11
14
|
def drop(n=1)
|
12
15
|
n.times do
|
@@ -16,14 +19,28 @@ module WithEase
|
|
16
19
|
end
|
17
20
|
def drop_fn = -> (n=1) { drop n }
|
18
21
|
|
22
|
+
def drop_while(&blk)
|
23
|
+
loop do
|
24
|
+
return self unless blk.(value)
|
25
|
+
advance
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def map(&blk)
|
30
|
+
lazy.map(&blk)
|
31
|
+
end
|
19
32
|
|
20
33
|
def each
|
21
34
|
loop do
|
22
35
|
yield value
|
23
|
-
|
36
|
+
advance
|
24
37
|
end
|
25
38
|
end
|
39
|
+
|
26
40
|
def take_fn = -> (n) { take n }
|
41
|
+
def take_while_fn = -> (&blk) { take_while(&blk) }
|
42
|
+
|
43
|
+
def to_proc = ->(*) { value }
|
27
44
|
|
28
45
|
private
|
29
46
|
def initialize(value, &advancer)
|
data/lib/with_ease/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: with_ease
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Dober
|
@@ -34,9 +34,12 @@ files:
|
|
34
34
|
- LICENSE
|
35
35
|
- README.md
|
36
36
|
- lib/with_ease.rb
|
37
|
+
- lib/with_ease/all.rb
|
38
|
+
- lib/with_ease/array_to_proc.rb
|
37
39
|
- lib/with_ease/base.rb
|
38
40
|
- lib/with_ease/closed_struct.rb
|
39
41
|
- lib/with_ease/closed_struct/hash_api.rb
|
42
|
+
- lib/with_ease/constructor_functions.rb
|
40
43
|
- lib/with_ease/forward.rb
|
41
44
|
- lib/with_ease/import_base.rb
|
42
45
|
- lib/with_ease/iterator.rb
|