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.



1943
1944
1945
1946
# File 'lib/syntax_tree/node.rb', line 1943

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

Instance Attribute Details

#nodeObject (readonly)

LBrace | Keyword

the node that is being represented



1941
1942
1943
# File 'lib/syntax_tree/node.rb', line 1941

def node
  @node
end

#textObject (readonly)

String

the actual output that should be printed



1938
1939
1940
# File 'lib/syntax_tree/node.rb', line 1938

def text
  @text
end

Instance Method Details

#commentsObject



1948
1949
1950
# File 'lib/syntax_tree/node.rb', line 1948

def comments
  node.comments
end

#format(q) ⇒ Object



1952
1953
1954
# File 'lib/syntax_tree/node.rb', line 1952

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