Permalink
Browse files

Now with lists!

  • Loading branch information...
1 parent fcf67c1 commit 8384d790aebbf3b31fa0b5d33f3e11d7edf0be1c @sephonicus committed Mar 8, 2012
Showing with 16 additions and 0 deletions.
  1. +16 −0 lib/chock/generator.rb
View
@@ -2,6 +2,7 @@ class Chock
class Generator
DEFAULT_QUANTITY = 1
DEFAULT_PARAGRAPH_SIZE = 5
+ DEFAULT_LIST_LENGTH = 3
@@modes = {}
def self.modes
@@ -36,5 +37,20 @@ def paragraphs(quantity=DEFAULT_QUANTITY, paragraph_size=DEFAULT_PARAGRAPH_SIZE)
"<h#{number}>#{sentence}</h#{number}>"
end
end
+
+ def list(items=DEFAULT_LIST_LENGTH, ordered=false)
+ components = ordered ? %w[<ol> </ol>] : %w[<ul> </ul>]
+ items.times { components[1, 0] = "<li>#{sentence}</li>" }
+ components.join
+ end
+
+ def ol(items=DEFAULT_LIST_LENGTH)
+ list(items, true)
+ end
+
+ def ul(items=DEFAULT_LIST_LENGTH)
+ list(items, false)
+ end
+
end
end

0 comments on commit 8384d79

Please sign in to comment.