Module: Gemmy::Patches::StringPatch::InstanceMethods::LineWrap
- Defined in:
- lib/gemmy/patches/string_patch.rb
Instance Method Summary collapse
-
#line_wrap(width, tabs = 4) ⇒ Object
facets wrap lines at width.
Instance Method Details
#line_wrap(width, tabs = 4) ⇒ Object
facets wrap lines at width
157 158 159 160 161 162 |
# File 'lib/gemmy/patches/string_patch.rb', line 157 def line_wrap(width, tabs=4) s = gsub(/\t/,' ' * tabs) # tabs default to 4 spaces s = s.gsub(/\n/,' ') r = s.scan( /.{1,#{width}}/ ) r.join("\n") << "\n" end |