Skip to content

Instantly share code, notes, and snippets.

@camerond
Last active December 11, 2015 17:58
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save camerond/4637757 to your computer and use it in GitHub Desktop.
Save camerond/4637757 to your computer and use it in GitHub Desktop.
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