Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module UiHelper
- def lorem(paras)
- paras = around(paras) if paras.is_a?(Range)
- Faker::Lorem.paragraphs(paras).map{|p| "<p>#{p}</p>"}.join.html_safe
- end
- def lorem_words(num)
- num = around(num) if num.is_a?(Range)
- Faker::Lorem.words(num).join(' ').html_safe
- end
- def around(range)
- range.to_a.sample
- end
- def sometimes(num=3)
- if num == around(1..num)
- yield
- end
- end
- def coinflip
- around([true, false])
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement