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.



1908
1909
1910
1911
# File 'lib/syntax_tree/node.rb', line 1908

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

Instance Attribute Details

#nodeObject (readonly)

LBrace | Keyword

the node that is being represented



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

def node
  @node
end

#textObject (readonly)

String

the actual output that should be printed



1903
1904
1905
# File 'lib/syntax_tree/node.rb', line 1903

def text
  @text
end

Instance Method Details

#commentsObject



1913
1914
1915
# File 'lib/syntax_tree/node.rb', line 1913

def comments
  node.comments
end

#format(q) ⇒ Object



1917
1918
1919
# File 'lib/syntax_tree/node.rb', line 1917

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