Class: SyntaxTree::ConditionalModFormatter
- Inherits:
-
Object
- Object
- SyntaxTree::ConditionalModFormatter
- Defined in:
- lib/syntax_tree/node.rb
Overview
Formats an IfMod or UnlessMod node.
Instance Attribute Summary collapse
-
#keyword ⇒ Object
readonly
- String
-
the keyword associated with this conditional.
-
#node ⇒ Object
readonly
- IfMod | UnlessMod
-
the node that is being formatted.
Instance Method Summary collapse
- #format(q) ⇒ Object
-
#initialize(keyword, node) ⇒ ConditionalModFormatter
constructor
A new instance of ConditionalModFormatter.
Constructor Details
#initialize(keyword, node) ⇒ ConditionalModFormatter
Returns a new instance of ConditionalModFormatter.
6062 6063 6064 6065 |
# File 'lib/syntax_tree/node.rb', line 6062 def initialize(keyword, node) @keyword = keyword @node = node end |
Instance Attribute Details
#keyword ⇒ Object (readonly)
- String
-
the keyword associated with this conditional
6057 6058 6059 |
# File 'lib/syntax_tree/node.rb', line 6057 def keyword @keyword end |
#node ⇒ Object (readonly)
- IfMod | UnlessMod
-
the node that is being formatted
6060 6061 6062 |
# File 'lib/syntax_tree/node.rb', line 6060 def node @node end |
Instance Method Details
#format(q) ⇒ Object
6067 6068 6069 6070 6071 6072 6073 |
# File 'lib/syntax_tree/node.rb', line 6067 def format(q) if ContainsAssignment.call(node.statement) || q.parent.is_a?(In) q.group { format_flat(q) } else q.group { q.if_break { format_break(q) }.if_flat { format_flat(q) } } end end |