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.



4318
4319
4320
4321
# File 'lib/syntax_tree/node.rb', line 4318

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

Instance Attribute Details

#nodeObject (readonly)

LBrace | Keyword

the node that is being represented



4316
4317
4318
# File 'lib/syntax_tree/node.rb', line 4316

def node
  @node
end

#textObject (readonly)

String

the actual output that should be printed



4313
4314
4315
# File 'lib/syntax_tree/node.rb', line 4313

def text
  @text
end

Instance Method Details

#commentsObject



4323
4324
4325
# File 'lib/syntax_tree/node.rb', line 4323

def comments
  node.comments
end

#format(q) ⇒ Object



4327
4328
4329
# File 'lib/syntax_tree/node.rb', line 4327

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