Ruby 4.0 リファレンスマニュアル

instance method PrettyPrint#group_sub

group_sub { ... } -> object[permalink][rdoc][edit]

ブロックを実行しながら、現在のグループより1段階深いグループをキューに追加します。

PrettyPrint#group と異なり、開き括弧・閉じ括弧の出力(PrettyPrint#text)やインデントの増加(PrettyPrint#nest)は行いません。PrettyPrint#group は内部でこのメソッドを使って実装されています。

require 'prettyprint'

out = PrettyPrint.format(''.dup, 5) do |q|
  q.group_sub {
    q.text 'hello'
    q.breakable
    q.text 'world'
  }
end
puts out
# => hello
#    world

[SEE_ALSO] PrettyPrint#group