60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/forgery/forgery/lorem_ipsum.rb', line 60
def self.paragraphs(quantity=2, options={})
default_options = {:separator => "\n\n",
:wrap => {
:start => "",
:end => "" },
:html => false,
:sentences => 3}
options = default_options.merge(options)
options.merge!(:random_limit => (dictionaries[:lorem_ipsum].length/options[:sentences])-quantity) if quantity.is_a?(Integer)
if options[:html]
options[:wrap] = { :start => "<p>",
:end => "</p>" }
end
range = range_from_quantity(quantity, options)
start = range.first * options[:sentences]
paragraphs = []
range.to_a.length.times do |i|
paragraphs << (
options[:wrap][:start] +
dictionaries[:lorem_ipsum][start..(start+options[:sentences]-1)].join(" ") +
options[:wrap][:end]
)
start += options[:sentences]
end
paragraphs.join(options[:separator])
end
|