Instantly share code, notes, and snippets.

Embed
What would you like to do?
My simple UI Helper in its more-or-less-current incarnation
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