Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. module UiHelper
  2.  
  3. def lorem(paras)
  4. paras = around(paras) if paras.is_a?(Range)
  5. Faker::Lorem.paragraphs(paras).map{|p| "<p>#{p}</p>"}.join.html_safe
  6. end
  7.  
  8. def lorem_words(num)
  9. num = around(num) if num.is_a?(Range)
  10. Faker::Lorem.words(num).join(' ').html_safe
  11. end
  12.  
  13. def around(range)
  14. range.to_a.sample
  15. end
  16.  
  17. def sometimes(num=3)
  18. if num == around(1..num)
  19. yield
  20. end
  21. end
  22.  
  23. def coinflip
  24. around([true, false])
  25. end
  26.  
  27. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement