class IcAgent::Ast::Nodes::StatementNode
Represents a statement node in the abstract syntax tree with additional attributes.
Attributes
child_count[RW]
Additional attributes to store child count and depth.
depth[RW]
Additional attributes to store child count and depth.
Public Instance Methods
add_child()
click to toggle source
Adds a child to the statement node.
# File lib/ic_agent/ast/nodes/statement_nodes.rb, line 32 def add_child @child_count ||= 0 + 1 end
elements_to_s()
click to toggle source
Converts the children of the statement node to a string.
# File lib/ic_agent/ast/nodes/statement_nodes.rb, line 27 def elements_to_s elements.map(&:to_s).join("\n") end
source_content()
click to toggle source
Returns the source content of the statement node by removing leading and trailing whitespaces.
# File lib/ic_agent/ast/nodes/statement_nodes.rb, line 37 def source_content self.text_value.strip end
title()
click to toggle source
The title of the statement node, by default :named_node.
# File lib/ic_agent/ast/nodes/statement_nodes.rb, line 12 def title :named_node end
to_array()
click to toggle source
Converts the statement node and its children to an array representation.
# File lib/ic_agent/ast/nodes/statement_nodes.rb, line 17 def to_array [title] + elements.map(&:to_array) end
to_s()
click to toggle source
Converts the statement node and its children to a string representation.
# File lib/ic_agent/ast/nodes/statement_nodes.rb, line 22 def to_s "#{title.to_s.upcase} #{elements_to_s}" end