algebrick 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/algebrick.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf3eb8ddaa209e039ffb7f1c70a6e72f5598b1c9
|
4
|
+
data.tar.gz: ebbd5d21d561f26c066b8a11da24620d24ec1b04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1aadc9051adf421099ef8e17878ae4d03fc9eb8dd91ecb430ac65fecaa999d54b26ea64844a012da0f8a43aa13bf6a2e0eabb5620ed84aef2dc6e88c82f9691e
|
7
|
+
data.tar.gz: 6aee2bb9d8ae13b4f71e61bfa40baa51696d4be1f45ce8a9f0f0898b628aee2f3234c9b92a86c700098ee9d86d8d9512f0d4e68c24f582398506392a6deddddf
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.3
|
data/lib/algebrick.rb
CHANGED
@@ -143,6 +143,16 @@ module Algebrick
|
|
143
143
|
raise "no match for (#{value.class}) '#{value}' by any of #{cases.map(&:first).join ', '}"
|
144
144
|
end
|
145
145
|
|
146
|
+
def on(matcher, value = nil, &block)
|
147
|
+
matcher = if matcher.is_a? Matchers::Abstract
|
148
|
+
matcher
|
149
|
+
else
|
150
|
+
matcher.to_m
|
151
|
+
end
|
152
|
+
raise ArgumentError, 'only one of block or value can be supplied' if block && value
|
153
|
+
[matcher, value || block]
|
154
|
+
end
|
155
|
+
|
146
156
|
# TODO #match! raise when match is not complete on a given type
|
147
157
|
|
148
158
|
private
|
@@ -828,6 +838,8 @@ module Algebrick
|
|
828
838
|
return self, block
|
829
839
|
end
|
830
840
|
|
841
|
+
alias_method :when, :case
|
842
|
+
|
831
843
|
def >(block)
|
832
844
|
return self, block
|
833
845
|
end
|
@@ -873,6 +885,10 @@ module Algebrick
|
|
873
885
|
end
|
874
886
|
end
|
875
887
|
|
888
|
+
def to_a
|
889
|
+
assigns
|
890
|
+
end
|
891
|
+
|
876
892
|
def ===(other)
|
877
893
|
matching?(other).tap { |matched| @value = other if (@matched = matched) }
|
878
894
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: algebrick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Petr Chalupa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11
|
11
|
+
date: 2013-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|