ranchodeluxemedia
1/27/2015 - 7:39 PM

ui_helper.rb

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