Sha256: 7a4a168b1f8a854f55d2dbd7f9be09fe3df02783a42c5abf6ee2f41a54be18c6
Contents?: true
Size: 598 Bytes
Versions: 5
Compression:
Stored size: 598 Bytes
Contents
class String # Provides a margin controlled string. # # x = %Q{ # | This # | is # | margin controlled! # }.margin # # # NOTE: This may still need a bit of tweaking. # # CREDIT: Trans def margin(n=0) #d = /\A.*\n\s*(.)/.match( self )[1] #d = /\A\s*(.)/.match( self)[1] unless d d = ((/\A.*\n\s*(.)/.match(self)) || (/\A\s*(.)/.match(self)))[1] return '' unless d if n == 0 gsub(/\n\s*\Z/,'').gsub(/^\s*[#{d}]/, '') else gsub(/\n\s*\Z/,'').gsub(/^\s*[#{d}]/, ' ' * n) end end end
Version data entries
5 entries across 5 versions & 1 rubygems