Class: SyntaxTree::DotFormatter
- Inherits:
-
Object
- Object
- SyntaxTree::DotFormatter
- Defined in:
- lib/syntax_tree/node.rb
Overview
Responsible for formatting Dot2 and Dot3 nodes.
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
- Dot2 | Dot3
-
the node that is being formatter.
-
#operator ⇒ Object
readonly
- String
-
the operator to display.
Instance Method Summary collapse
- #format(q) ⇒ Object
-
#initialize(operator, node) ⇒ DotFormatter
constructor
A new instance of DotFormatter.
Constructor Details
#initialize(operator, node) ⇒ DotFormatter
Returns a new instance of DotFormatter.
3752 3753 3754 3755 |
# File 'lib/syntax_tree/node.rb', line 3752 def initialize(operator, node) @operator = operator @node = node end |
Instance Attribute Details
#node ⇒ Object (readonly)
- Dot2 | Dot3
-
the node that is being formatter
3750 3751 3752 |
# File 'lib/syntax_tree/node.rb', line 3750 def node @node end |
#operator ⇒ Object (readonly)
- String
-
the operator to display
3747 3748 3749 |
# File 'lib/syntax_tree/node.rb', line 3747 def operator @operator end |
Instance Method Details
#format(q) ⇒ Object
3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 |
# File 'lib/syntax_tree/node.rb', line 3757 def format(q) space = [If, IfMod, Unless, UnlessMod].include?(q.parent.class) left = node.left right = node.right q.format(left) if left q.text(" ") if space q.text(operator) q.text(" ") if space q.format(right) if right end |