Top Level Namespace
Defined Under Namespace
Modules: Packrat Classes: Regexp, String, Symbol
Instance Method Summary collapse
-
#lputs(str) ⇒ Object
A version of puts that limits output to 80 columns width.
Instance Method Details
#lputs(str) ⇒ Object
A version of puts that limits output to 80 columns width
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/packrat/grammar.rb', line 6 def lputs(str) tabs = 0 len = (0...(str.length)).inject(0) do |l,i| if str[i,1] == "\t" tabs += 1 l + 8 else l + 1 end end if len > 80 s = str[0,80-3-(tabs*8)] + "..." else s = str end puts s end |