Skip to content

Commit

Permalink
Now with lists!
Browse files Browse the repository at this point in the history
  • Loading branch information
sephonicus committed Mar 8, 2012
1 parent fcf67c1 commit 8384d79
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/chock/generator.rb
Expand Up @@ -2,6 +2,7 @@ class Chock
class Generator
DEFAULT_QUANTITY = 1
DEFAULT_PARAGRAPH_SIZE = 5
DEFAULT_LIST_LENGTH = 3

@@modes = {}
def self.modes
Expand Down Expand Up @@ -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.