mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add indexer methods for captured arguments
This commit is contained in:
parent
4aaed186c3
commit
29389f1dbf
2 changed files with 30 additions and 0 deletions
|
@ -27,6 +27,16 @@ module Spectator
|
|||
{{@type.name(generic_args: false)}}.capture
|
||||
end
|
||||
|
||||
# Returns the positional argument at the specified index.
|
||||
def [](index : Int)
|
||||
@args[index]
|
||||
end
|
||||
|
||||
# Returns the specified named argument.
|
||||
def [](arg : Symbol)
|
||||
@kwargs[arg]
|
||||
end
|
||||
|
||||
# Constructs a string representation of the arguments.
|
||||
def to_s(io : IO) : Nil
|
||||
return io << "(no args)" if args.empty? && kwargs.empty?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue