mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Implement Indexable(Node) on ExampleGroup
This commit is contained in:
parent
4e5a52215a
commit
837e4cb85d
1 changed files with 3 additions and 12 deletions
|
@ -5,9 +5,8 @@ require "./node"
|
||||||
module Spectator
|
module Spectator
|
||||||
# Collection of examples and sub-groups.
|
# Collection of examples and sub-groups.
|
||||||
class ExampleGroup < Node
|
class ExampleGroup < Node
|
||||||
include Enumerable(Node)
|
|
||||||
include Hooks
|
include Hooks
|
||||||
include Iterable(Node)
|
include Indexable(Node)
|
||||||
|
|
||||||
@nodes = [] of Node
|
@nodes = [] of Node
|
||||||
|
|
||||||
|
@ -71,6 +70,8 @@ module Spectator
|
||||||
group << self if group
|
group << self if group
|
||||||
end
|
end
|
||||||
|
|
||||||
|
delegate size, unsafe_fetch, to: @nodes
|
||||||
|
|
||||||
# Creates a child that is attched to the group.
|
# Creates a child that is attched to the group.
|
||||||
# Yields zero or more times to create the child.
|
# Yields zero or more times to create the child.
|
||||||
# The group the child should be attached to is provided as a block argument.
|
# The group the child should be attached to is provided as a block argument.
|
||||||
|
@ -88,16 +89,6 @@ module Spectator
|
||||||
@nodes.delete(node)
|
@nodes.delete(node)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Yields each node (example and sub-group).
|
|
||||||
def each
|
|
||||||
@nodes.each { |node| yield node }
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns an iterator for each (example and sub-group).
|
|
||||||
def each
|
|
||||||
@nodes.each
|
|
||||||
end
|
|
||||||
|
|
||||||
# Checks if all examples and sub-groups have finished.
|
# Checks if all examples and sub-groups have finished.
|
||||||
def finished? : Bool
|
def finished? : Bool
|
||||||
@nodes.all?(&.finished?)
|
@nodes.all?(&.finished?)
|
||||||
|
|
Loading…
Reference in a new issue