Class: TreeHaver::Backends::Psych::Tree
- Inherits:
-
TreeHaver::Base::Tree
- Object
- TreeHaver::Base::Tree
- TreeHaver::Backends::Psych::Tree
- Defined in:
- lib/tree_haver/backends/psych.rb
Overview
Psych tree wrapper
Wraps a Psych::Nodes::Stream to provide TreeHaver-compatible tree interface.
Instance Attribute Summary collapse
-
#inner_tree ⇒ ::Psych::Nodes::Stream
readonly
The underlying Psych stream.
Attributes inherited from TreeHaver::Base::Tree
Instance Method Summary collapse
-
#initialize(stream, source) ⇒ Tree
constructor
Create a new tree wrapper.
-
#inspect ⇒ Object
Human-readable representation.
-
#root_node ⇒ Node
Get the root node.
Methods inherited from TreeHaver::Base::Tree
#comments, #edit, #errors, #has_error?, #warnings
Constructor Details
#initialize(stream, source) ⇒ Tree
Create a new tree wrapper
163 164 165 |
# File 'lib/tree_haver/backends/psych.rb', line 163 def initialize(stream, source) super(stream, source: source) end |
Instance Attribute Details
#inner_tree ⇒ ::Psych::Nodes::Stream (readonly)
Returns The underlying Psych stream.
157 158 159 |
# File 'lib/tree_haver/backends/psych.rb', line 157 def inner_tree @inner_tree end |
Instance Method Details
#inspect ⇒ Object
Human-readable representation
175 176 177 |
# File 'lib/tree_haver/backends/psych.rb', line 175 def inspect "#<TreeHaver::Backends::Psych::Tree documents=#{inner_tree.children&.size || 0}>" end |
#root_node ⇒ Node
Get the root node
170 171 172 |
# File 'lib/tree_haver/backends/psych.rb', line 170 def root_node Node.new(inner_tree, source: source, lines: lines) end |