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.



4269
4270
4271
4272
# File 'lib/syntax_tree/node.rb', line 4269

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

Instance Attribute Details

#nodeObject (readonly)

LBrace | Keyword

the node that is being represented



4267
4268
4269
# File 'lib/syntax_tree/node.rb', line 4267

def node
  @node
end

#textObject (readonly)

String

the actual output that should be printed



4264
4265
4266
# File 'lib/syntax_tree/node.rb', line 4264

def text
  @text
end

Instance Method Details

#commentsObject



4274
4275
4276
# File 'lib/syntax_tree/node.rb', line 4274

def comments
  node.comments
end

#format(q) ⇒ Object



4278
4279
4280
# File 'lib/syntax_tree/node.rb', line 4278

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