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.



4234
4235
4236
4237
# File 'lib/syntax_tree/node.rb', line 4234

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

Instance Attribute Details

#nodeObject (readonly)

LBrace | Keyword

the node that is being represented



4232
4233
4234
# File 'lib/syntax_tree/node.rb', line 4232

def node
  @node
end

#textObject (readonly)

String

the actual output that should be printed



4229
4230
4231
# File 'lib/syntax_tree/node.rb', line 4229

def text
  @text
end

Instance Method Details

#commentsObject



4239
4240
4241
# File 'lib/syntax_tree/node.rb', line 4239

def comments
  node.comments
end

#format(q) ⇒ Object



4243
4244
4245
# File 'lib/syntax_tree/node.rb', line 4243

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