Class: PrettyPrint::Indent

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/prettyprint.rb

Overview

A node in the print tree that is a variant of the Align node that indents its contents by one level.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents: []) ⇒ Indent

Returns a new instance of Indent.



198
199
200
# File 'lib/syntax_tree/prettyprint.rb', line 198

def initialize(contents: [])
  @contents = contents
end

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



196
197
198
# File 'lib/syntax_tree/prettyprint.rb', line 196

def contents
  @contents
end

Instance Method Details

#pretty_print(q) ⇒ Object



202
203
204
205
206
# File 'lib/syntax_tree/prettyprint.rb', line 202

def pretty_print(q)
  q.group(2, "indent([", "])") do
    q.seplist(contents) { |content| q.pp(content) }
  end
end