Class: PrettierPrint::Align

Inherits:
Object
  • Object
show all
Defined in:
lib/prettier_print.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.



68
69
70
71
# File 'lib/prettier_print.rb', line 68

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

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



66
67
68
# File 'lib/prettier_print.rb', line 66

def contents
  @contents
end

#indentObject (readonly)

Returns the value of attribute indent.



66
67
68
# File 'lib/prettier_print.rb', line 66

def indent
  @indent
end

Instance Method Details

#pretty_print(q) ⇒ Object



73
74
75
76
77
# File 'lib/prettier_print.rb', line 73

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