mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Handle nil labels
This commit is contained in:
parent
0992bad7eb
commit
97923d6bcd
2 changed files with 10 additions and 3 deletions
|
@ -16,7 +16,7 @@ module Spectator
|
|||
# The *proc* will be called to evaluate the value of the expression.
|
||||
# The *label* is usually the Crystal code for the *proc*.
|
||||
# It can be nil if it isn't available.
|
||||
def initialize(@block : -> T, label : Label)
|
||||
def initialize(@block : -> T, label : Label = nil)
|
||||
super(label)
|
||||
end
|
||||
|
||||
|
@ -24,7 +24,7 @@ module Spectator
|
|||
# The block will be called to evaluate the value of the expression.
|
||||
# The *label* is usually the Crystal code for the *block*.
|
||||
# It can be nil if it isn't available.
|
||||
def initialize(label : Label, &@block : -> T)
|
||||
def initialize(label : Label = nil, &@block : -> T)
|
||||
super(label)
|
||||
end
|
||||
|
||||
|
|
|
@ -14,9 +14,16 @@ module Spectator
|
|||
# Creates the value.
|
||||
# Expects the *value* of the expression and a *label* describing it.
|
||||
# The *label* is usually the Crystal code evaluating to the *value*.
|
||||
# It can be nil if it isn't available.
|
||||
def initialize(@value : T, label : Label)
|
||||
super(label)
|
||||
end
|
||||
|
||||
# Creates the value.
|
||||
# Expects the *value* of the expression.
|
||||
# It can be nil if it isn't available.
|
||||
# A label is generated by calling `#inspect` on the *value*.
|
||||
def initialize(@value : T)
|
||||
super(@value.inspect)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue