mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Initial work on match data values management
This commit is contained in:
parent
51c267896f
commit
0b467012cb
4 changed files with 39 additions and 3 deletions
15
src/spectator/matchers/generic_match_data_value.cr
Normal file
15
src/spectator/matchers/generic_match_data_value.cr
Normal file
|
@ -0,0 +1,15 @@
|
|||
require "./match_data_value"
|
||||
|
||||
module Spectator::Matchers
|
||||
# Wraps a value for used in match data.
|
||||
private struct GenericMatchDataValue(T) < MatchDataValue
|
||||
# Creates the wrapper.
|
||||
def initialize(@value : T)
|
||||
end
|
||||
|
||||
# Stringifies the value.
|
||||
def to_s(io)
|
||||
@value.inspect(io)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -12,9 +12,9 @@ module Spectator::Matchers
|
|||
end
|
||||
|
||||
# Information about the match.
|
||||
# Returned value and type will differ by sub-type,
|
||||
# but all will return a set of key-value pairs.
|
||||
abstract def values
|
||||
# Returned elments will differ by matcher,
|
||||
# but all will return a set of labeled values.
|
||||
abstract def values : Array(MatchDataLabeledValue)
|
||||
|
||||
# Describes the condition that satisfies the matcher.
|
||||
# This is informational and displayed to the end-user.
|
||||
|
|
15
src/spectator/matchers/match_data_labeled_value.cr
Normal file
15
src/spectator/matchers/match_data_labeled_value.cr
Normal file
|
@ -0,0 +1,15 @@
|
|||
module Spectator::Matchers
|
||||
# A value from match data with a label.
|
||||
private struct MatchDataLabeledValue
|
||||
# Label tied to the value.
|
||||
# This annotates what the value is.
|
||||
getter label : String
|
||||
|
||||
# The actual value from the match data.
|
||||
getter value : MatchDataValue
|
||||
|
||||
# Creates a new labeled value.
|
||||
def initialize(@label, @value)
|
||||
end
|
||||
end
|
||||
end
|
6
src/spectator/matchers/match_data_value.cr
Normal file
6
src/spectator/matchers/match_data_value.cr
Normal file
|
@ -0,0 +1,6 @@
|
|||
module Spectator::Matchers
|
||||
# Abstract base for all match data values.
|
||||
# All sub-classes are expected to implement their own `#to_s`.
|
||||
private abstract struct MatchDataValue
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue