ect 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -2
  3. data/README.md +88 -1
  4. data/ect.gemspec +1 -1
  5. data/lib/ect.rb +18 -1
  6. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5126d9a6b41dac42288d17490888f694db777cd9
4
- data.tar.gz: 8921d691ff8243ca99c5ba1c97cef8788fb3ce16
3
+ metadata.gz: 39640ca9b5241c26a75af47e0a1ecd2958921512
4
+ data.tar.gz: 5010a8c7eea35df1e08308d7c919674002b10ae9
5
5
  SHA512:
6
- metadata.gz: b2f6db49f856706f42544c71a5839304b469b22e2901d2be363a2476af9559c807bc247b5473bca009b1fea5e354dc205b55e8aa1661821bb58a85740f60dcb1
7
- data.tar.gz: 1df6f620b267f9372d2bbd902e26b9a59efccfd9be4f850e162920d3d85503f08d08220af1255af5becb9a53bb70100160bf1b0195c1445922c0ac9a5aebbda3
6
+ metadata.gz: aff7be833138964e1964a41411035fc15b5ac1c425d07e38f8305d8e1813445832664f7c21dee05d5aeb097cb20c0699ec5f332500e3fb419695384dac694be8
7
+ data.tar.gz: 59a427f2a7154d9337e28d5bd01ea3673ce6f5c529fa522f8c16f818b37111cd5a5884aad0015cd68119ff22011c31abc837236d89148500b406d4cd6a17b36f
@@ -2,7 +2,15 @@
2
2
  # ect CHANGELOG.md
3
3
 
4
4
 
5
- ## ect 1.0.0 not yet released
5
+ ## ect 1.0.0 released 2017-10-13
6
6
 
7
- - alias #bisect to Enumerable#partition
7
+ - Alias #inflect to Object#tap
8
+ - Implement Object#deflect
9
+ - Implement Enumerable#dissect
10
+ - Alias #bisect to Enumerable#partition
11
+
12
+
13
+ ## ect 0.0.1 released 2017-10-12
14
+
15
+ - Empty initial gem push
8
16
 
data/README.md CHANGED
@@ -3,7 +3,94 @@
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/et-orbi.svg)](http://badge.fury.io/rb/ect)
5
5
 
6
- Methods ending in `ect`.
6
+ Ruby methods ending in `ect`.
7
+
8
+ The subject of last part of a [lightning talk](https://speakerdeck.com/jmettraux/ruby-methods-in-ect-hiroshima-dot-rb-number-058) for [Hiroshima.rb #058](https://hiroshimarb.connpass.com/event/65459/).
9
+
10
+ I like to chain methods ending in `ect`. I wanted to have more of them.
11
+
12
+ Mostly a joke.
13
+
14
+
15
+ ## Object
16
+
17
+ ### Object#inflect
18
+
19
+ > inflect |ɪnˈflɛkt|
20
+ >
21
+ > ORIGIN late Middle English (in sense 3): from Latin inflectere, from in- ‘into’ + flectere ‘to bend’.
22
+
23
+ An alias to `#tap`. Passes the instance to the block, returns the instance.
24
+
25
+ ```ruby
26
+ %w[ fox lion crow donkey wolf ]
27
+ .inflect { |a| a << 'mole' }
28
+ .collect(&:capitalize)
29
+ ```
30
+
31
+ ### Object#deflect
32
+
33
+ > deflect |dɪˈflɛkt|
34
+ >
35
+ > ORIGIN mid 16th cent.: from Latin deflectere, from de- ‘away from’ + flectere ‘to bend’.
36
+
37
+ A very simple `yield(self)` (in Ruby 2.5.x it could thus become an alias to `#yiel_self`).
38
+
39
+ Passes the instance to the block, returns the result of the block. Change of direction.
40
+
41
+ ```ruby
42
+ [ animals_list_1, animals_list_2 ]
43
+ .deflect { |a, b| a.include?('mole') ? a : b }
44
+ .collect(&:capitalize)
45
+ ```
46
+
47
+ ## Enumerable
48
+
49
+ ### Enumerable#bisect
50
+
51
+ > bisect |bʌɪˈsɛkt|
52
+ >
53
+ > ORIGIN mid 17th cent.: from bi-‘two’ + Latin sect- (from secare ‘to cut’).
54
+
55
+ An alias to `#partition`. Returns two arrays (the true array and the false array).
56
+
57
+ ```ruby
58
+ %w[ fox lion crow donkey wolf ]
59
+ .bisect { |a| a.length > 3 }
60
+ #
61
+ # => [ %w[ lion crow donkey wolf ],
62
+ # %w[ fox ] ]
63
+ ```
64
+
65
+ ### Enumerable#dissect
66
+
67
+ > dissect |dʌɪˈsɛkt, dɪ-|
68
+ >
69
+ > ORIGIN late 16th cent.: from Latin dissect- ‘cut up’, from the verb dissecare, from dis- ‘apart’ + secare ‘to cut’.
70
+
71
+ "Cuts" the incoming Enumerable instance in multiple arrays.
72
+
73
+ ```ruby
74
+ a0, a1, a2 = (1..14).dissect { |i| i % 3 }
75
+
76
+ p a0 # => [ 3, 6, 9, 12 ]
77
+ p a1 # => [ 1, 4, 7, 10, 13 ]
78
+ p a2 # => [ 2, 5, 8, 11, 14 ]
79
+ ```
80
+
81
+ A sparse answer is possible:
82
+ ```ruby
83
+ a0, a1, a2 = (1..14)
84
+ .dissect { |i|
85
+ case m = i % 3
86
+ when 0, 2 then m
87
+ else 0
88
+ end }
89
+
90
+ p a0 # => [ 1, 3, 4, 6, 7, 9, 10, 12, 13 ]
91
+ p a1 # => nil
92
+ p a2 # => [ 2, 5, 8, 11, 14 ]
93
+ ```
7
94
 
8
95
 
9
96
  ## LICENSE
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.summary = 'Methods ending in ect'
16
16
 
17
17
  s.description = %{
18
- Methods ending in ect
18
+ Methods ending in ect. Mostly a joke.
19
19
  }.strip
20
20
 
21
21
  #s.files = `git ls-files`.split("\n")
data/lib/ect.rb CHANGED
@@ -1,11 +1,28 @@
1
1
 
2
2
  module Ect
3
3
 
4
- VERSION = '0.0.1'
4
+ VERSION = '1.0.0'
5
5
  end
6
6
 
7
+
8
+ class Object
9
+
10
+ alias inflect tap
11
+
12
+ def deflect
13
+
14
+ yield(self)
15
+ end
16
+ end
17
+
18
+
7
19
  module Enumerable
8
20
 
9
21
  alias bisect partition
22
+
23
+ def dissect
24
+
25
+ inject([]) { |a, elt| (a[yield(elt)] ||= []) << elt; a }
26
+ end
10
27
  end
11
28
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-12 00:00:00.000000000 Z
11
+ date: 2017-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.6'
27
- description: Methods ending in ect
27
+ description: Methods ending in ect. Mostly a joke.
28
28
  email:
29
29
  - jmettraux@gmail.com
30
30
  executables: []