PageRenderTime 135ms CodeModel.GetById 83ms app.highlight 8ms RepoModel.GetById 12ms app.codeStats 0ms

/lib/widgets/utils_helper.rb

http://github.com/paolodona/rails-widgets
Ruby | 23 lines | 18 code | 2 blank | 3 comment | 2 complexity | 405dc45e95a5fce436a51d3b56075e77 MD5 | raw file
Possible License(s): MIT
 1module Widgets
 2  module UtilsHelper
 3    def nocr(string)
 4      return string.gsub("\n", '')
 5    end
 6  
 7    # converts blank spaces into no breaking spaces
 8    # use it like <%=nbsp ...%>
 9    def nbsp(string)
10      string.to_s.gsub " ", "&nbsp;"
11    end 
12  
13    # generates random text to fill up not-yet-implemented interfaces
14    def lorem(n=nil)
15      words = %w{Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.} 
16      if n 
17        while (n > words.size) do words = words + words; end 
18        words = words[0..n]    
19      end
20      return words.join(' ') 
21    end
22  end  
23end