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.



4248
4249
4250
4251
# File 'lib/syntax_tree/node.rb', line 4248

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

Instance Attribute Details

#nodeObject (readonly)

LBrace | Keyword

the node that is being represented



4246
4247
4248
# File 'lib/syntax_tree/node.rb', line 4246

def node
  @node
end

#textObject (readonly)

String

the actual output that should be printed



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

def text
  @text
end

Instance Method Details

#commentsObject



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

def comments
  node.comments
end

#format(q) ⇒ Object



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

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