Sha256: b613ca09147d9cf2db615ae63a347c36bac16201753c572c5f82c0089b54e386
Contents?: true
Size: 655 Bytes
Versions: 12
Compression:
Stored size: 655 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. # # TODO: describe its limits and caveats and edge cases # # 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
12 entries across 11 versions & 1 rubygems