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.



4257
4258
4259
4260
# File 'lib/syntax_tree/node.rb', line 4257

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

Instance Attribute Details

#nodeObject (readonly)

LBrace | Keyword

the node that is being represented



4255
4256
4257
# File 'lib/syntax_tree/node.rb', line 4255

def node
  @node
end

#textObject (readonly)

String

the actual output that should be printed



4252
4253
4254
# File 'lib/syntax_tree/node.rb', line 4252

def text
  @text
end

Instance Method Details

#commentsObject



4262
4263
4264
# File 'lib/syntax_tree/node.rb', line 4262

def comments
  node.comments
end

#format(q) ⇒ Object



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

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