Module: LoremIpsum::Base
- Defined in:
- lib/lorem_ipsum/base.rb
Defined Under Namespace
Classes: IncorrectFormat, NoMasError
Instance Method Summary collapse
Instance Method Details
#lorem_ipsum(arg) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/lorem_ipsum/base.rb', line 7 def lorem_ipsum(arg) if /(\d+)([w|c|s|p])/i.match(arg) num = $1.to_i case $2.downcase when "w" then word(num) when "c" then character(num) when "s" then sentence(num) when "p" then paragraph(num) end else raise IncorrectFormat, "lorem_ipsum understands '1c' for one character, '1w' for one word, '1s' for one sentence, '5p' for five paragraphs, etc." end end |