Class: PrettierPrint::IfFlatIgnore

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

Overview

When we already know that groups are broken, we don’t actually need to track the flat versions of the contents. So this builder version is effectively a no-op, but we need it to maintain the same API. The only thing this can impact is that if there’s a forced break in the flat contents, then we need to propagate that break up the whole tree.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(q) ⇒ IfFlatIgnore

Returns a new instance of IfFlatIgnore.



895
896
897
# File 'lib/prettier_print.rb', line 895

def initialize(q)
  @q = q
end

Instance Attribute Details

#qObject (readonly)

Returns the value of attribute q.



893
894
895
# File 'lib/prettier_print.rb', line 893

def q
  @q
end

Instance Method Details

#if_flatObject



899
900
901
902
903
904
905
# File 'lib/prettier_print.rb', line 899

def if_flat
  contents = []
  group = Group.new(0, contents: contents)

  q.with_target(contents) { yield }
  q.break_parent if group.break?
end