mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add ascend methods
This commit is contained in:
parent
8d366bf637
commit
c209fe7259
2 changed files with 16 additions and 5 deletions
|
@ -151,6 +151,15 @@ module Spectator
|
|||
klass.cast(@context)
|
||||
end
|
||||
|
||||
# Yields this example and all parent groups.
|
||||
def ascend
|
||||
node = self
|
||||
while node
|
||||
yield node
|
||||
node = node.group?
|
||||
end
|
||||
end
|
||||
|
||||
# Constructs the full name or description of the example.
|
||||
# This prepends names of groups this example is part of.
|
||||
def to_s(io)
|
||||
|
|
|
@ -72,11 +72,13 @@ module Spectator
|
|||
|
||||
delegate size, unsafe_fetch, to: @nodes
|
||||
|
||||
# Creates a child that is attched to the group.
|
||||
# Yields zero or more times to create the child.
|
||||
# The group the child should be attached to is provided as a block argument.
|
||||
def create_child
|
||||
yield self
|
||||
# Yields this group and all parent groups.
|
||||
def ascend
|
||||
group = self
|
||||
while group
|
||||
yield group
|
||||
group = group.group?
|
||||
end
|
||||
end
|
||||
|
||||
# Removes the specified *node* from the group.
|
||||
|
|
Loading…
Reference in a new issue