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
3875 3876 3877 3878 |
# File 'lib/syntax_tree/node.rb', line 3875 def initialize(operator, node) @operator = operator @node = node end |
Instance Attribute Details
#node ⇒ Object (readonly)
- Dot2 | Dot3
-
the node that is being formatter
3873 3874 3875 |
# File 'lib/syntax_tree/node.rb', line 3873 def node @node end |
#operator ⇒ Object (readonly)
- String
-
the operator to display
3870 3871 3872 |
# File 'lib/syntax_tree/node.rb', line 3870 def operator @operator end |
Instance Method Details
#format(q) ⇒ Object
3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 |
# File 'lib/syntax_tree/node.rb', line 3880 def format(q) left = node.left right = node.right q.format(left) if left case q.parent when If, IfMod, Unless, UnlessMod q.text(" #{operator} ") else q.text(operator) end q.format(right) if right end |