Class: SyntaxTree::DotFormatter
- Inherits:
-
Object
- Object
- SyntaxTree::DotFormatter
- Defined in:
- lib/syntax_tree.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.
4907 4908 4909 4910 |
# File 'lib/syntax_tree.rb', line 4907 def initialize(operator, node) @operator = operator @node = node end |
Instance Attribute Details
#node ⇒ Object (readonly)
- Dot2 | Dot3
-
the node that is being formatter
4905 4906 4907 |
# File 'lib/syntax_tree.rb', line 4905 def node @node end |
#operator ⇒ Object (readonly)
- String
-
the operator to display
4902 4903 4904 |
# File 'lib/syntax_tree.rb', line 4902 def operator @operator end |
Instance Method Details
#format(q) ⇒ Object
4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 |
# File 'lib/syntax_tree.rb', line 4912 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 |