method_matchable 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -1
- data/lib/method_matchable.rb +3 -6
- data/lib/method_matchable/base.rb +9 -0
- data/lib/method_matchable/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3947cb25e3939810fbea082dd65c60b6e970a46a06eacf601bc35aff93212639
|
4
|
+
data.tar.gz: 3d5de65719547b57360988be18ed21b4fee2b5d8841648c6688ba8704dd7b543
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7337a741ca40073dbfcc3b08ffa4949205dfee9f22de2e87913c5b85415b3137e810c95fdf24db5a84b7cab9ae7430078554a33727d8ff5c241b77c2be8074b7
|
7
|
+
data.tar.gz: f25f58a376062315bb9d4beff786371974449bd729f2597df2b043d63fdf4759651ffd037790b5ed478afc926615b38e1625b2a2553f35458850a4c2973c4e50
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# MethodMatchable
|
2
2
|
|
3
|
+
[![CircleCI](https://circleci.com/gh/kokuyouwind/method_matchable.svg?style=svg)](https://circleci.com/gh/kokuyouwind/method_matchable)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/method_matchable.svg)](https://badge.fury.io/rb/method_matchable)
|
5
|
+
|
3
6
|
Match with methods in hash patterns!
|
4
7
|
|
5
8
|
## Installation
|
@@ -23,7 +26,7 @@ Or install it yourself as:
|
|
23
26
|
|
24
27
|
```ruby
|
25
28
|
Person = Struct.new(:first_name, :last_name) do
|
26
|
-
include MethodMatchable
|
29
|
+
include MethodMatchable::Base
|
27
30
|
|
28
31
|
def full_name
|
29
32
|
"#{first_name} #{last_name}"
|
@@ -34,6 +37,17 @@ case Person.new('Hotaru', 'Shiragiku')
|
|
34
37
|
in { full_name: name }
|
35
38
|
p name # => 'Hotaru Shiragiku'
|
36
39
|
end
|
40
|
+
|
41
|
+
# You can use both original keys and method keys
|
42
|
+
class Hash
|
43
|
+
prepend MethodMatchable::Base
|
44
|
+
end
|
45
|
+
|
46
|
+
case { key: :value}
|
47
|
+
in { key: v, size: size}
|
48
|
+
p v # => :value
|
49
|
+
p size # => 1
|
50
|
+
end
|
37
51
|
```
|
38
52
|
|
39
53
|
## Development
|
data/lib/method_matchable.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: method_matchable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kokuyouwind
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- bin/console
|
72
72
|
- bin/setup
|
73
73
|
- lib/method_matchable.rb
|
74
|
+
- lib/method_matchable/base.rb
|
74
75
|
- lib/method_matchable/version.rb
|
75
76
|
- method_matchable.gemspec
|
76
77
|
homepage: https://github.com/kokuyouwind/method_matchable
|