to_proc 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cea0e4a1ede76dbf5111b7760ce54c851918b482
4
- data.tar.gz: ddb73554b6e41a338619678a3df31c707dd76d07
3
+ metadata.gz: 26e32799d86106d07c04df61e0f233424abaa594
4
+ data.tar.gz: 16d7bbd701584993d6b90d40bc1c5bc9aef2d2a4
5
5
  SHA512:
6
- metadata.gz: 98702c848376d6edd09578c1ab4670048eaa5ebbfa834783d6235f8b66c87e933cd6dc54745c04efdfb7a050ed93beaa1396bffd5e51d8d1d7e8b8f7123f8e0b
7
- data.tar.gz: 7f42bf89d19361ab269dcf53b928cdefd6a975cfda843673438bc98ad331aba5597ae18bda75036d543741952dd57d990dccb82c564029b9c0dc6854e2db68dc
6
+ metadata.gz: b09b963ca2506360ca7635f24bba6f9eb262a7ad215104bb390a085387b2829a72eb56648f6c271150b4c8eede6ec1b43919929b7d122d30aed1ac178447efa4
7
+ data.tar.gz: 53b19f2614fc30b13fbf32e875a712357a5474b9761331c97b7a42f9a6d368f754e1a376ee2ae06bdb2a539b6c16482961c817473089506e4fc6ba59813e6039
@@ -0,0 +1,19 @@
1
+ class Array
2
+ def to_proc
3
+ if self[0].is_a? Symbol
4
+ method, *arguments = self
5
+ -> receiver { receiver.send method, *arguments }
6
+ elsif self[1].is_a? Symbol
7
+ receiver, method, *arguments = self
8
+ if arguments.empty?
9
+ -> argument { receiver.send method, argument }
10
+ else
11
+ # if some arguments were passed as well,
12
+ # what is more reasonable for collection element?
13
+ # to become the first or the last argument?
14
+ end
15
+ else
16
+ super
17
+ end
18
+ end
19
+ end
data/lib/to_proc/all.rb CHANGED
@@ -1,4 +1,7 @@
1
1
  require 'to_proc'
2
2
 
3
+ Object.include ToProc[:[]]
4
+ Class.include ToProc[:new]
5
+ require 'to_proc/Array'
6
+
3
7
  require 'to_proc/try'
4
- require 'to_proc/sugar'
data/to_proc.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |g|
2
2
  g.name = 'to_proc'
3
3
  g.files = `git ls-files`.split($/)
4
- g.version = '0.0.1'
4
+ g.version = '0.0.2'
5
5
  g.summary = 'What if almost any object were a proc?'
6
6
  g.authors = ['Anatoly Chernow']
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: to_proc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anatoly Chernow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-03 00:00:00.000000000 Z
11
+ date: 2016-10-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -17,6 +17,7 @@ extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
19
  - lib/to_proc.rb
20
+ - lib/to_proc/Array.rb
20
21
  - lib/to_proc/all.rb
21
22
  - lib/to_proc/sugar.rb
22
23
  - lib/to_proc/try.rb