mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Make Example comparable against names and sources
This will be needed for filtering examples.
This commit is contained in:
parent
4f3ca20741
commit
2f8b4761de
3 changed files with 140 additions and 0 deletions
|
@ -59,5 +59,21 @@ module Spectator
|
|||
def to_json(json : ::JSON::Builder)
|
||||
json.string(to_s)
|
||||
end
|
||||
|
||||
# Checks if this example matches some criteria.
|
||||
# This is used to filter examples.
|
||||
def ===(other)
|
||||
other === to_s
|
||||
end
|
||||
|
||||
# Checks if this example is at the specified source.
|
||||
def ===(other : Source)
|
||||
source == other
|
||||
end
|
||||
|
||||
# Checks if this example is at the specified line number.
|
||||
def ===(other : Int32)
|
||||
source.line === other
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue