Module: UiHelper
- Defined in:
- app/helpers/ui_helper.rb
Instance Method Summary collapse
- #around(range) ⇒ Object
- #coinflip ⇒ Object
- #lorem(paras) ⇒ Object
- #lorem_words(num) ⇒ Object
- #sometimes(num = 3) ⇒ Object
Instance Method Details
#around(range) ⇒ Object
2 3 4 |
# File 'app/helpers/ui_helper.rb', line 2 def around(range) range.to_a.sample end |
#coinflip ⇒ Object
16 17 18 |
# File 'app/helpers/ui_helper.rb', line 16 def coinflip around([true, false]) end |
#lorem(paras) ⇒ Object
6 7 8 9 |
# File 'app/helpers/ui_helper.rb', line 6 def lorem(paras) paras = around(paras) if paras.is_a?(Range) Faker::Lorem.paragraphs(paras).map{|p| "<p>#{p}</p>"}.join.html_safe end |
#lorem_words(num) ⇒ Object
11 12 13 14 |
# File 'app/helpers/ui_helper.rb', line 11 def lorem_words(num) num = around(num) if num.is_a?(Range) Faker::Lorem.words(num).join(' ') end |
#sometimes(num = 3) ⇒ Object
20 21 22 |
# File 'app/helpers/ui_helper.rb', line 20 def sometimes(num = 3) yield if num == around(1..num) end |