Module: Mab::Indentation
- Included in:
- PrettyBuilder
- Defined in:
- lib/mab/indentation.rb
Instance Method Summary collapse
Instance Method Details
#mab_done(tag) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mab/indentation.rb', line 12 def mab_done(tag) if blk = tag.block tag.block = proc do begin @mab_context.[:indentation] += 1 blk.call ensure @mab_context.[:indentation] -= 1 end end end super end |
#mab_insert(str) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/mab/indentation.rb', line 3 def mab_insert(str) if i = @mab_context.[:indentation] super([$/ + " " * i, str]) else @mab_context.[:indentation] = 0 super end end |
#reindent!(str) ⇒ Object
26 27 28 29 30 |
# File 'lib/mab/indentation.rb', line 26 def reindent!(str) str.split(/\r?\n/).each do |s| text! s end end |