Class: String
Instance Method Summary collapse
- #___indent(n) ⇒ Object
-
#___margin ⇒ Object
adapted from ‘facets’ project.
- #___truncate(n) ⇒ Object
Instance Method Details
#___indent(n) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/whitestone/support.rb', line 4 def ___indent(n) if n >= 0 gsub(/^/, ' ' * n) else gsub(/^ {0,#{-n}}/, "") end end |
#___margin ⇒ Object
adapted from ‘facets’ project
21 22 23 24 25 26 |
# File 'lib/whitestone/support.rb', line 21 def ___margin # adapted from 'facets' project d = ((/\A.*\n\s*(.)/.match(self)) || (/\A\s*(.)/.match(self)))[1] return '' unless d gsub(/\n\s*\Z/,'').gsub(/^\s*[#{d}]/, '') end |
#___truncate(n) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/whitestone/support.rb', line 12 def ___truncate(n) str = self if str.length > n str[0...n] + "..." else str end end |