Module: Roebe::WordWrap
- Defined in:
- lib/roebe/classes/word_wrap.rb
Overview
Roebe::WordWrap
Constant Summary collapse
- N_CHARACTERS_LIMIT =
#
N_CHARACTERS_LIMIT
Specify the default line width here.
#
80
Class Method Summary collapse
-
.[](i, n_characters_limit = :default) ⇒ Object
# === Roebe::WordWrap[] ========================================================================= #.
Class Method Details
.[](i, n_characters_limit = :default) ⇒ Object
#
Roebe::WordWrap[]
#
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/roebe/classes/word_wrap.rb', line 29 def self.[]( i, n_characters_limit = :default ) case n_characters_limit # ======================================================================= # # === :default # ======================================================================= # when :default n_characters_limit = N_CHARACTERS_LIMIT end if i.is_a? Array i.flatten! if File.exist?(i.first) # Handle existing files here. i = File.readlines(i.first) end end i = i.join("\n") if i.is_a? Array begin i.gsub!(/(.{1,#{n_characters_limit}})(\s+|$)/, "\\1\n") rescue ArgumentError => error p error end return i end |