syntax_tree_ext 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/syntax_tree_ext/version.rb +1 -1
- data/lib/syntax_tree_ext.rb +16 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce3e3738a614af69fd2ca73be682d1516281057cacbf1995445b07bab29f3020
|
4
|
+
data.tar.gz: f47da333553dcbf262cf53ae2685d999fda7a9a8800498b84b783ae0344e9365
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc2e4c15334228eccb81faa35fc93b3f068a5d0951e03f7e8ecaa352e0a76940b6af46fd2bdf6aa32d039d74515cd070aed220d61743b97ab0fa245967656e49
|
7
|
+
data.tar.gz: 9c454a2b46e308630496ae20baca6adcadd5a7f70b2b9401068f3b3e9cd9a516412145c5a593543759f45e1aae540bf13365a97609643a4848baabf03beb6098
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/syntax_tree_ext.rb
CHANGED
@@ -54,6 +54,22 @@ module SyntaxTree
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
+
def hash_assoc(key)
|
58
|
+
if is_a?(BareAssocHash) || is_a?(HashLiteral)
|
59
|
+
assocs.find { |assoc_node| assoc_node.key.to_value == key }
|
60
|
+
else
|
61
|
+
raise MethodNotSupported, "hash_assoc is not supported for #{self}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def hash_value(key)
|
66
|
+
if is_a?(BareAssocHash) || is_a?(HashLiteral)
|
67
|
+
assocs.find { |assoc_node| assoc_node.key.to_value == key }&.value
|
68
|
+
else
|
69
|
+
raise MethodNotSupported, "hash_value is not supported for #{self}"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
57
73
|
def to_value
|
58
74
|
case self
|
59
75
|
when SymbolLiteral
|