Class: PrettyPrint::Align

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

Overview

A node in the print tree that represents aligning nested nodes to a certain prefix width or string.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(indent:, contents: []) ⇒ Align

Returns a new instance of Align.



76
77
78
79
# File 'lib/syntax_tree/prettyprint.rb', line 76

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

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



74
75
76
# File 'lib/syntax_tree/prettyprint.rb', line 74

def contents
  @contents
end

#indentObject (readonly)

Returns the value of attribute indent.



74
75
76
# File 'lib/syntax_tree/prettyprint.rb', line 74

def indent
  @indent
end

Instance Method Details

#pretty_print(q) ⇒ Object



81
82
83
84
85
# File 'lib/syntax_tree/prettyprint.rb', line 81

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