Class: Fakerama::Content
- Inherits:
-
Object
- Object
- Fakerama::Content
- Extended by:
- ActionView::Helpers::TagHelper
- Defined in:
- lib/fakerama/content.rb
Class Method Summary collapse
- .content ⇒ Object
- .filled_tag(tag_name, type = :sentence, count = 3) ⇒ Object
- .headings(range = 1..6) ⇒ Object
- .list(*args) ⇒ Object
- .paragraphs(count = 1) ⇒ Object (also: paragraph)
Class Method Details
.content ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fakerama/content.rb', line 32 def content [paragraphs(3), headings(2..5), filled_tag(:blockquote), paragraph, list(:ol, 5), paragraph, list(:ul, 3), paragraphs(4)].shuffle.join end |
.filled_tag(tag_name, type = :sentence, count = 3) ⇒ Object
28 29 30 |
# File 'lib/fakerama/content.rb', line 28 def filled_tag(tag_name, type = :sentence, count = 3) content_tag( tag_name, Faker::Lorem.send(type, count)) end |
.headings(range = 1..6) ⇒ Object
6 7 8 9 10 |
# File 'lib/fakerama/content.rb', line 6 def headings(range = 1..6) range.map do |size| [filled_tag("h#{size}"), paragraph].join end.join end |
.list(*args) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/fakerama/content.rb', line 12 def list(*args) list_type = (args.first.to_s == 'ol') ? 'ol' : 'ul' items = args.last.to_i.times.map do |i| content_tag( :li, Faker::Lorem.sentence ) end.join content_tag(list_type, items, {}, false) end |
.paragraphs(count = 1) ⇒ Object Also known as: paragraph
20 21 22 23 24 |
# File 'lib/fakerama/content.rb', line 20 def paragraphs(count=1) count.times.map do content_tag( :p, Faker::Lorem.paragraph ) end.join end |