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



1970
1971
1972
1973
# File 'lib/syntax_tree/node.rb', line 1970

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

Instance Attribute Details

#nodeObject (readonly)

LBrace | Keyword

the node that is being represented



1968
1969
1970
# File 'lib/syntax_tree/node.rb', line 1968

def node
  @node
end

#textObject (readonly)

String

the actual output that should be printed



1965
1966
1967
# File 'lib/syntax_tree/node.rb', line 1965

def text
  @text
end

Instance Method Details

#commentsObject



1975
1976
1977
# File 'lib/syntax_tree/node.rb', line 1975

def comments
  node.comments
end

#format(q) ⇒ Object



1979
1980
1981
# File 'lib/syntax_tree/node.rb', line 1979

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