mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Shorten compare_values case statements
This commit is contained in:
parent
556d4783bf
commit
526a998e41
1 changed files with 6 additions and 15 deletions
|
@ -45,23 +45,14 @@ module Spectator
|
||||||
when Range
|
when Range
|
||||||
# Ranges can only be matched against if their right side is comparable.
|
# Ranges can only be matched against if their right side is comparable.
|
||||||
# Ensure the right side is comparable, otherwise compare directly.
|
# Ensure the right side is comparable, otherwise compare directly.
|
||||||
if b.is_a?(Comparable(typeof(b)))
|
return a === b if b.is_a?(Comparable(typeof(b)))
|
||||||
a === b
|
a == b
|
||||||
else
|
|
||||||
a == b
|
|
||||||
end
|
|
||||||
when Tuple, Array
|
when Tuple, Array
|
||||||
if b.is_a?(Tuple) || b.is_a?(Array)
|
return compare_tuples(a, b) if b.is_a?(Tuple) || b.is_a?(Array)
|
||||||
compare_tuples(a, b)
|
a === b
|
||||||
else
|
|
||||||
a === b
|
|
||||||
end
|
|
||||||
when NamedTuple, Hash
|
when NamedTuple, Hash
|
||||||
if b.is_a?(NamedTuple) || b.is_a?(Hash)
|
return compare_named_tuples(a, b) if b.is_a?(NamedTuple) || b.is_a?(Hash)
|
||||||
compare_named_tuples(a, b)
|
a === b
|
||||||
else
|
|
||||||
a === b
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
a === b
|
a === b
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue