Class: SyntaxTree::ConditionalModFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree.rb

Overview

Formats an IfMod or UnlessMod node.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keyword, node) ⇒ ConditionalModFormatter

Returns a new instance of ConditionalModFormatter.



7249
7250
7251
7252
# File 'lib/syntax_tree.rb', line 7249

def initialize(keyword, node)
  @keyword = keyword
  @node = node
end

Instance Attribute Details

#keywordObject (readonly)

String

the keyword associated with this conditional



7244
7245
7246
# File 'lib/syntax_tree.rb', line 7244

def keyword
  @keyword
end

#nodeObject (readonly)

IfMod | UnlessMod

the node that is being formatted



7247
7248
7249
# File 'lib/syntax_tree.rb', line 7247

def node
  @node
end

Instance Method Details

#format(q) ⇒ Object



7254
7255
7256
7257
7258
7259
7260
# File 'lib/syntax_tree.rb', line 7254

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