class
Sheen::Tree::Branch
- Sheen::Tree::Branch
- Sheen::Tree::Node
- Reference
- Object
Overview
A node in a tree.
An implementation of Node with children and a builder API.
Defined in:
sheen/tree.crConstructors
- .new(value : String = "", hidden : Bool = false)
-
.root(value) : Branch
Builds a tree already rooted at value.
Instance Method Summary
-
#child(value : Branch) : Branch
Appends a child
Branch. -
#child(value : Children) : Branch
Appends each node from value as a child.
-
#child(value : Node) : Branch
Appends value as a child node.
-
#child(value : Array) : Branch
Appends each element of value as a child.
-
#child(value : Nil) : Branch
Skips nil, adding no child.
- #child(value) : Branch
-
#child(*values) : Branch
Appends one or more child values to the tree.
-
#children : Children
A copy of the tree's children.
-
#config : Config | Nil
This node's render configuration, or
nilwhile it inherits its parent's. -
#enumerator(enumr : Enumerator) : Branch
Sets the branch-prefix enumerator.
-
#enumerator(&block : Children, Int32 -> String) : Branch
Sets the branch-prefix enumerator from a block.
-
#enumerator(kind : Enumerators) : Branch
Convenience method to set one of the builtin enumerator styles by kind.
-
#enumerator_style(style : Style) : Branch
Sets one static style for every enumerator prefix.
-
#enumerator_style(&block : Children, Int32 -> Style) : Branch
Sets the enumerator style block, invoked per child.
-
#hidden? : Bool
If this node is hidden from rendering or not.
-
#hide(hidden : Bool = true) : Branch
Sets whether the tree is hidden from rendering.
-
#indenter(ind : Indenter) : Branch
Sets the indenter used for nested children.
-
#indenter(&block : Children, Int32 -> String) : Branch
Sets the indenter used for nested children from a block.
-
#item_style(style : Style) : Branch
Sets one static style for every item's value.
-
#item_style(&block : Children, Int32 -> Style) : Branch
Sets the item style block, invoked per child for conditional styling.
-
#render : String
Renders the whole tree to a string using this node's configuration, or
Configdefaults if none have been set. -
#root(value : Branch) : Branch
Sets value as the root and appends its children.
-
#root(value) : Branch
Sets value as the root.
-
#root_style(style : Style) : Branch
Sets the style applied to the root node's value.
-
#to_s(io : IO) : Nil
Render the tree to io.
-
#value : String
The node's display value.
Instance methods inherited from class Sheen::Tree::Node
children : Children
children,
hidden? : Bool
hidden?,
to_s(io : IO) : Nil
to_s,
value : String
value
Constructor Detail
Builds a tree already rooted at value.
Shorthand for new.root(value)
Instance Method Detail
Appends a child Branch. A rootless value auto-nests onto the previous sibling, otherwise it is appended.
Returns self.
Appends each node from value as a child.
Returns self.
Appends each element of value as a child.
Returns self.
Appends one or more child values to the tree.
Returns self.
This node's render configuration, or nil while it inherits its parent's.
Sets the branch-prefix enumerator.
Returns self.
Sets the branch-prefix enumerator from a block.
Returns self.
Convenience method to set one of the builtin enumerator styles by kind. eg #enumerator(:rounded)
Returns self.
Sets one static style for every enumerator prefix.
Returns self.
Sets the enumerator style block, invoked per child.
Returns self.
Sets the indenter used for nested children.
Returns self.
Sets the indenter used for nested children from a block.
Returns self.
Sets one static style for every item's value.
Returns self.
Sets the item style block, invoked per child for conditional styling.
Returns self.
Renders the whole tree to a string using this node's configuration, or Config defaults if none have been set.
Sets value as the root and appends its children.
Returns self.
Sets the style applied to the root node's value.
Returns self.