Class: SyntaxTree::BlockFormatter::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.



1896
1897
1898
1899
# File 'lib/syntax_tree/node.rb', line 1896

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

Instance Attribute Details

#nodeObject (readonly)

LBrace | Keyword

the node that is being represented



1894
1895
1896
# File 'lib/syntax_tree/node.rb', line 1894

def node
  @node
end

#textObject (readonly)

String

the actual output that should be printed



1891
1892
1893
# File 'lib/syntax_tree/node.rb', line 1891

def text
  @text
end

Instance Method Details

#commentsObject



1901
1902
1903
# File 'lib/syntax_tree/node.rb', line 1901

def comments
  node.comments
end

#format(q) ⇒ Object



1905
1906
1907
# File 'lib/syntax_tree/node.rb', line 1905

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