juxt 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -3
- data/lib/juxt/version.rb +1 -1
- data/lib/juxt.rb +8 -6
- metadata +2 -2
data/README.md
CHANGED
@@ -14,9 +14,9 @@ Example
|
|
14
14
|
{:foo => 'foo', :bar => 'bar'}.juxt :foo, :bar
|
15
15
|
# ['foo', 'bar']
|
16
16
|
|
17
|
-
# Need to create a hash from some Object properties?
|
18
|
-
|
19
|
-
Hash[
|
17
|
+
# Need to create a hash from some Object properties/method/attributes?
|
18
|
+
arr = ['foo', 'bar']
|
19
|
+
Hash[arr.map_juxt :upcase, :reverse]
|
20
20
|
# {'FOO' => 'oof', 'BAR' => 'rab'}
|
21
21
|
```
|
22
22
|
|
data/lib/juxt/version.rb
CHANGED
data/lib/juxt.rb
CHANGED
@@ -2,12 +2,7 @@ require "juxt/version"
|
|
2
2
|
|
3
3
|
class Object
|
4
4
|
def juxtapose(*args)
|
5
|
-
[*args].map
|
6
|
-
case self
|
7
|
-
when Hash then self[x.to_sym] || self[x.to_s] || self[x]
|
8
|
-
else send x
|
9
|
-
end
|
10
|
-
end
|
5
|
+
[*args].map{ |x| send x }
|
11
6
|
end
|
12
7
|
alias juxt juxtapose
|
13
8
|
end
|
@@ -17,4 +12,11 @@ class Array
|
|
17
12
|
map{ |e| e.juxtapose *args }
|
18
13
|
end
|
19
14
|
alias map_juxt map_juxtapose
|
15
|
+
alias juxt values_at
|
16
|
+
alias juxtapose values_at
|
20
17
|
end
|
18
|
+
|
19
|
+
class Hash
|
20
|
+
alias juxt values_at
|
21
|
+
alias juxtapose values_at
|
22
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: juxt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|