module RubyClasses::String

Constants

LOREM_IPSUM

Public Instance Methods

autoregex(anything) click to toggle source

supports: strings, arrays and regexes :) @returns a Regexp

    # File lib/ruby_classes/strings.rb
259 def autoregex(anything)
260   deb "Autoregex() supercool! With a #{blue anything.class}"
261   case anything.class.to_s
262     when 'String' 
263       if anything.match(/^\/.*\/$/) # '/asd/' is probably an error! The regex builder trails with '/' automatically
264         fatal 23,"Attention, the regex is a string with trailing '/', are you really SURE this is what you want?!?"
265       end
266       return  Regexp.new(anything)
267     when 'Regexp'
268       return anything # already ok
269     when 'Array'
270       return Regexp.new(anything.join('|'))
271     else
272       msg = "Unknown class for autoregexing: #{red anything.class}"
273       $stderr.puts( msg )
274       raise( msg )
275   end
276   return nil
277 end
clear()
Alias for: clear_screen
clear_screen() click to toggle source

Miscellaneous string functions

    # File lib/ruby_classes/strings.rb
225 def clear_screen
226   print "\e[2J\e[f"
227 end
Also aliased as: clear
lorem(len=0)
Alias for: lorem_ipsum
lorem_ipsum(len=0) click to toggle source
    # File lib/ruby_classes/strings.rb
249 def lorem_ipsum(len=0)
250   len == 0 ? 
251     LOREM_IPSUM :
252     LOREM_IPSUM[0..len]
253 end
Also aliased as: lorem
title(s) click to toggle source
    # File lib/ruby_classes/strings.rb
230 def title(s)
231   title_n(s)
232 end
title_n(s,n=2) click to toggle source
    # File lib/ruby_classes/strings.rb
233 def title_n(s,n=2)
234   "== #{s} =="
235 end