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.



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

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

Instance Attribute Details

#nodeObject (readonly)

LBrace | Keyword

the node that is being represented



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

def node
  @node
end

#textObject (readonly)

String

the actual output that should be printed



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

def text
  @text
end

Instance Method Details

#commentsObject



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

def comments
  node.comments
end

#format(q) ⇒ Object



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

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