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 *proc* will be called to evaluate the value of the expression.
|
||||||
# The *label* is usually the Crystal code for the *proc*.
|
# The *label* is usually the Crystal code for the *proc*.
|
||||||
# It can be nil if it isn't available.
|
# It can be nil if it isn't available.
|
||||||
def initialize(@block : -> T, label : Label)
|
def initialize(@block : -> T, label : Label = nil)
|
||||||
super(label)
|
super(label)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ module Spectator
|
||||||
# The block will be called to evaluate the value of the expression.
|
# The block will be called to evaluate the value of the expression.
|
||||||
# The *label* is usually the Crystal code for the *block*.
|
# The *label* is usually the Crystal code for the *block*.
|
||||||
# It can be nil if it isn't available.
|
# It can be nil if it isn't available.
|
||||||
def initialize(label : Label, &@block : -> T)
|
def initialize(label : Label = nil, &@block : -> T)
|
||||||
super(label)
|
super(label)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,16 @@ module Spectator
|
||||||
# Creates the value.
|
# Creates the value.
|
||||||
# Expects the *value* of the expression and a *label* describing it.
|
# Expects the *value* of the expression and a *label* describing it.
|
||||||
# The *label* is usually the Crystal code evaluating to the *value*.
|
# 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)
|
def initialize(@value : T, label : Label)
|
||||||
super(label)
|
super(label)
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue