Last active
December 11, 2015 17:58
-
-
Save camerond/4637757 to your computer and use it in GitHub Desktop.
My simple UI Helper in its more-or-less-current incarnation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment