Class: PrettyPrint::Align
- Inherits:
-
Object
- Object
- PrettyPrint::Align
- 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
-
#contents ⇒ Object
readonly
Returns the value of attribute contents.
-
#indent ⇒ Object
readonly
Returns the value of attribute indent.
Instance Method Summary collapse
-
#initialize(indent:, contents: []) ⇒ Align
constructor
A new instance of Align.
- #pretty_print(q) ⇒ Object
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
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
74 75 76 |
# File 'lib/syntax_tree/prettyprint.rb', line 74 def contents @contents end |
#indent ⇒ Object (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 |