fancy_to_proc 0.1.1 → 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 +14 -3
- data/lib/fancy_to_proc.rb +4 -0
- data/lib/fancy_to_proc/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d0d378fd1815f35453d06e44ca5012d21f55eb3
|
4
|
+
data.tar.gz: 56e8b70b14b3a60e89894d2d6ceba931ebc3c52f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 793358d118d5927f34d63ad7be85dc1bf343e257395c63f228e9e1926456dea1df19e2256129f124e7e9243083e50afad6efb602152a5584d0739fd7521642ad
|
7
|
+
data.tar.gz: 9ad1da09a2d5eea8a373b0fa211fb30e07df71b19dda82b63d2d5de19c088ce90a3f329eca874257a20dc0be194ba55c6c6a3ad11d0e5509c10341143f7e0ae8
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Fancy to_proc
|
1
|
+
# 🎩 Fancy to_proc
|
2
2
|
|
3
3
|
Have you ever wished Symbol#to_proc was chainable and took arguments?
|
4
4
|
|
@@ -7,7 +7,8 @@ Have you ever wished Symbol#to_proc was chainable and took arguments?
|
|
7
7
|
#=> ["Banana", "Haddock!"]
|
8
8
|
```
|
9
9
|
|
10
|
-
Well now it can!
|
10
|
+
Well now it can! Read on to see how to use it, or even better [read my post](https://www.sfcgeorge.co.uk/posts/2015/09/21/why-ruby-symbol-to-proc-works-and-more) explaining how it works with pictures.
|
11
|
+
|
11
12
|
|
12
13
|
## Methods
|
13
14
|
|
@@ -35,6 +36,16 @@ Yep, pass whatever arguments you like to your symbol method, very convenient!
|
|
35
36
|
Note the dot before the brackets, it's short for `.call()` which you can also use.
|
36
37
|
|
37
38
|
|
39
|
+
### [] with arguments
|
40
|
+
|
41
|
+
This is just an alternate syntax for the above `call` option, specifically designed to make enumerable indexing a little nicer:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
[{ thing: "banana" }, { thing: "hammock!" }].map &:[][:thing]
|
45
|
+
#=> ["banana", "hammock!"]
|
46
|
+
```
|
47
|
+
|
48
|
+
|
38
49
|
### ~ method tilde
|
39
50
|
|
40
51
|
Instead of the method being called on the yielded object, the object(s) is passed to the method. How often have you wanted to do this:
|
@@ -139,7 +150,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
139
150
|
|
140
151
|
## Contributing
|
141
152
|
|
142
|
-
1. Fork it ( https://github.com/
|
153
|
+
1. Fork it ( https://github.com/sfcgeorge/fancy_to_proc/fork )
|
143
154
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
144
155
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
145
156
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/fancy_to_proc.rb
CHANGED