Class: SyntaxTree::ConditionalModFormatter
- Inherits:
-
Object
- Object
- SyntaxTree::ConditionalModFormatter
- Defined in:
- lib/syntax_tree.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.
7117 7118 7119 7120 |
# File 'lib/syntax_tree.rb', line 7117 def initialize(keyword, node) @keyword = keyword @node = node end |
Instance Attribute Details
#keyword ⇒ Object (readonly)
- String
-
the keyword associated with this conditional
7112 7113 7114 |
# File 'lib/syntax_tree.rb', line 7112 def keyword @keyword end |
#node ⇒ Object (readonly)
- IfMod | UnlessMod
-
the node that is being formatted
7115 7116 7117 |
# File 'lib/syntax_tree.rb', line 7115 def node @node end |
Instance Method Details
#format(q) ⇒ Object
7122 7123 7124 7125 7126 7127 7128 |
# File 'lib/syntax_tree.rb', line 7122 def format(q) if ContainsAssignment.call(node.statement) q.group { format_flat(q) } else q.group { q.if_break { format_break(q) }.if_flat { format_flat(q) } } end end |