mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Docs
This commit is contained in:
parent
5dfc60d4cd
commit
6c98d7107c
3 changed files with 16 additions and 4 deletions
|
@ -1,14 +1,19 @@
|
|||
module Spectator
|
||||
# Equals and matches everything.
|
||||
# All comparison methods will always return true.
|
||||
struct Anything
|
||||
def ==(other)
|
||||
# Returns true for equality.
|
||||
def ==(_other)
|
||||
true
|
||||
end
|
||||
|
||||
def ===(other)
|
||||
# Returns true for case equality.
|
||||
def ===(_other)
|
||||
true
|
||||
end
|
||||
|
||||
def =~(other)
|
||||
# Returns true for matching.
|
||||
def =~(_other)
|
||||
true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,10 +4,17 @@
|
|||
# This type is intentionally outside the `Spectator` module.
|
||||
# The reason for this is to prevent name collision when using the DSL to define a spec.
|
||||
abstract class SpectatorContext
|
||||
# Produces a dummy string to represent the context as a string.
|
||||
# This prevents the default behavior, which normally stringifies instance variables.
|
||||
# Due to the sheer amount of types Spectator can create
|
||||
# and that the Crystal compiler instantiates a `#to_s` and/or `#inspect` for each of those types,
|
||||
# an explosion in method instances can be created.
|
||||
# The compile time is drastically reduced by using a dummy string instead.
|
||||
def to_s(io)
|
||||
io << "Context"
|
||||
end
|
||||
|
||||
# :ditto:
|
||||
def inspect(io)
|
||||
io << "Context<"
|
||||
io << self.class
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require "json"
|
||||
|
||||
module Spectator
|
||||
# Define the file and line number something originated from.
|
||||
# Defines the file and line numbers something originated from.
|
||||
struct Source
|
||||
# Absolute file path.
|
||||
getter file : String
|
||||
|
|
Loading…
Reference in a new issue