Class: PrettierPrint::IfBreakBuilder

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

Overview

A small DSL-like object used for specifying the alternative contents to be printed if the surrounding group doesn’t break for an IfBreak node.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(q, flat_contents) ⇒ IfBreakBuilder

Returns a new instance of IfBreakBuilder.



877
878
879
880
# File 'lib/prettier_print.rb', line 877

def initialize(q, flat_contents)
  @q = q
  @flat_contents = flat_contents
end

Instance Attribute Details

#flat_contentsObject (readonly)

Returns the value of attribute flat_contents.



875
876
877
# File 'lib/prettier_print.rb', line 875

def flat_contents
  @flat_contents
end

#qObject (readonly)

Returns the value of attribute q.



875
876
877
# File 'lib/prettier_print.rb', line 875

def q
  @q
end

Instance Method Details

#if_flatObject



882
883
884
# File 'lib/prettier_print.rb', line 882

def if_flat
  q.with_target(flat_contents) { yield }
end