mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Transform named tuple match data to array
Trying to keep some of the existing code (and better syntax).
This commit is contained in:
parent
66bd1555ac
commit
8d3ab0d44c
1 changed files with 20 additions and 1 deletions
|
@ -1,3 +1,7 @@
|
|||
require "./match_data_labeled_value"
|
||||
require "./match_data_value"
|
||||
require "./generic_match-data_value"
|
||||
|
||||
module Spectator::Matchers
|
||||
# Information regarding a expectation parial and matcher.
|
||||
# `Matcher#match` will return a sub-type of this.
|
||||
|
@ -14,7 +18,22 @@ module Spectator::Matchers
|
|||
# Information about the match.
|
||||
# Returned elments will differ by matcher,
|
||||
# but all will return a set of labeled values.
|
||||
abstract def values : Array(MatchDataLabeledValue)
|
||||
def values : Array(MatchDataLabeledValue)
|
||||
named_tuple.map do |key, value|
|
||||
if value.is_a?(MatchDataValue)
|
||||
MatchDataLabeledValue.new(key, value)
|
||||
else
|
||||
wrapper = GenericMatchDataValue.new(value)
|
||||
MatchDataLabeledValue.new(key, wrapper)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Raw information about the match.
|
||||
# Sub-types must implement this and return a `NamedTuple`
|
||||
# containing the match data values.
|
||||
# This will be transformed and returned by `#values`.
|
||||
private abstract def named_tuple
|
||||
|
||||
# Describes the condition that satisfies the matcher.
|
||||
# This is informational and displayed to the end-user.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue