code-ruby 5.2.2 → 5.2.3
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 +4 -4
- data/VERSION +1 -1
- data/lib/code/concerns/shared.rb +13 -0
- data/lib/code/object.rb +5 -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: ff9e2eb63fe68f38a6beb3082b3b625aebed51c35aa77c326d525f67f0fa2975
|
|
4
|
+
data.tar.gz: 164677f0a8bc720bfcba991b9dc95799f4737fc25e42bcd88de70fe6d0dd4fe1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f5fd63680c00619761715a35a294d0dbf03d0a8979f611c2e9e7cd76a2876c52215d10a0d1ddc0a2d63de7090836dad6d8f983faa976df148c3d71191b9cd609
|
|
7
|
+
data.tar.gz: 313a8c168da2e41951dddfe2365d0c058ff186f42f8128581b11f03a414ee17d81346f6aa4848697e5d5fbe76b69a2d5b384576acc83fbc13578d97b6e05d36f
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
5.2.
|
|
1
|
+
5.2.3
|
data/lib/code/concerns/shared.rb
CHANGED
|
@@ -22,6 +22,7 @@ class Code
|
|
|
22
22
|
SHARED_OPERATORS = %w[
|
|
23
23
|
documentation
|
|
24
24
|
present?
|
|
25
|
+
in?
|
|
25
26
|
blank?
|
|
26
27
|
presence
|
|
27
28
|
presence_in
|
|
@@ -161,6 +162,9 @@ class Code
|
|
|
161
162
|
when "==", "equal", "equal?"
|
|
162
163
|
sig(args) { Object }
|
|
163
164
|
code_equal(code_value)
|
|
165
|
+
when "in?"
|
|
166
|
+
sig(args) { Object::List | Object::Range | Object::String | Object::Dictionary }
|
|
167
|
+
code_in?(code_value)
|
|
164
168
|
when "same_object?"
|
|
165
169
|
sig(args) { Object }
|
|
166
170
|
code_same_object?(code_value)
|
|
@@ -391,6 +395,15 @@ class Code
|
|
|
391
395
|
Object::Boolean.new((self <=> code_other) <= 0)
|
|
392
396
|
end
|
|
393
397
|
|
|
398
|
+
def code_in?(collection)
|
|
399
|
+
collection = collection.to_code
|
|
400
|
+
if collection.is_a?(Object::Dictionary)
|
|
401
|
+
collection.code_has_key?(self)
|
|
402
|
+
else
|
|
403
|
+
collection.code_include?(self)
|
|
404
|
+
end
|
|
405
|
+
end
|
|
406
|
+
|
|
394
407
|
def code_exclamation_mark
|
|
395
408
|
Object::Boolean.new(falsy?)
|
|
396
409
|
end
|
data/lib/code/object.rb
CHANGED
|
@@ -17,6 +17,11 @@ class Code
|
|
|
17
17
|
examples: %w[Object Object.new Object.documentation.description]
|
|
18
18
|
}.freeze
|
|
19
19
|
INSTANCE_FUNCTIONS = {
|
|
20
|
+
"in?" => {
|
|
21
|
+
name: "in?",
|
|
22
|
+
description: "checks whether a collection includes this value.",
|
|
23
|
+
examples: ["200.in?(200...300)", "300.in?(200...300)", ":ok.in?([:ok, :accepted])"]
|
|
24
|
+
},
|
|
20
25
|
"documentation" => {
|
|
21
26
|
name: "documentation",
|
|
22
27
|
description: "returns documentation for the value's class.",
|