Class: SyntaxTree::BlockNode::BlockOpenFormatter

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

Overview

Formats the opening brace or keyword of a block.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, node) ⇒ BlockOpenFormatter

Returns a new instance of BlockOpenFormatter.



4336
4337
4338
4339
# File 'lib/syntax_tree/node.rb', line 4336

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

Instance Attribute Details

#nodeObject (readonly)

LBrace | Keyword

the node that is being represented



4334
4335
4336
# File 'lib/syntax_tree/node.rb', line 4334

def node
  @node
end

#textObject (readonly)

String

the actual output that should be printed



4331
4332
4333
# File 'lib/syntax_tree/node.rb', line 4331

def text
  @text
end

Instance Method Details

#commentsObject



4341
4342
4343
# File 'lib/syntax_tree/node.rb', line 4341

def comments
  node.comments
end

#format(q) ⇒ Object



4345
4346
4347
# File 'lib/syntax_tree/node.rb', line 4345

def format(q)
  q.text(text)
end