Class: PrettyPrint::LineSuffix
- Inherits:
-
Object
- Object
- PrettyPrint::LineSuffix
- Defined in:
- lib/syntax_tree/prettyprint.rb
Overview
A node in the print tree that has its own special buffer for implementing content that should flush before any newline.
Useful for implementating trailing content, as it’s not always practical to constantly check where the line ends to avoid accidentally printing some content after a line suffix node.
Constant Summary collapse
- DEFAULT_PRIORITY =
1
Instance Attribute Summary collapse
-
#contents ⇒ Object
readonly
Returns the value of attribute contents.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
Instance Method Summary collapse
-
#initialize(priority: DEFAULT_PRIORITY, contents: []) ⇒ LineSuffix
constructor
A new instance of LineSuffix.
- #pretty_print(q) ⇒ Object
Constructor Details
#initialize(priority: DEFAULT_PRIORITY, contents: []) ⇒ LineSuffix
Returns a new instance of LineSuffix.
222 223 224 225 |
# File 'lib/syntax_tree/prettyprint.rb', line 222 def initialize(priority: DEFAULT_PRIORITY, contents: []) @priority = priority @contents = contents end |
Instance Attribute Details
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
220 221 222 |
# File 'lib/syntax_tree/prettyprint.rb', line 220 def contents @contents end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
220 221 222 |
# File 'lib/syntax_tree/prettyprint.rb', line 220 def priority @priority end |
Instance Method Details
#pretty_print(q) ⇒ Object
227 228 229 230 231 |
# File 'lib/syntax_tree/prettyprint.rb', line 227 def pretty_print(q) q.group(2, "line-suffix([", "])") do q.seplist(contents) { |content| q.pp(content) } end end |