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.



200
201
202
# File 'lib/syntax_tree/prettyprint.rb', line 200

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

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



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

def contents
  @contents
end

Instance Method Details

#pretty_print(q) ⇒ Object



204
205
206
207
208
# File 'lib/syntax_tree/prettyprint.rb', line 204

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