Class: Propolize::PropositionWithExplanation
- Inherits:
-
Object
- Object
- Propolize::PropositionWithExplanation
- Defined in:
- lib/propolize.rb
Overview
A proposition with an explanation. The proposition is effectively the headline, and the explanation is a sequence of “explanation items” (i.e. paragraphs or lists).
Instance Method Summary collapse
-
#addExplanationItem(item) ⇒ Object
Add one explanation item to the list of explanation items.
-
#dump(indent) ⇒ Object
Dump to stdout (for debugging/tracing).
-
#initialize(proposition) ⇒ PropositionWithExplanation
constructor
Create with initial proposition (and empty list of explanation items).
-
#toHtml ⇒ Object
Output as HTML (Each proposition is one item in a list of propositions, so it is output as a <li> item.).
Constructor Details
#initialize(proposition) ⇒ PropositionWithExplanation
Create with initial proposition (and empty list of explanation items)
109 110 111 112 |
# File 'lib/propolize.rb', line 109 def initialize(proposition) @proposition = proposition @explanationItems = [] end |
Instance Method Details
#addExplanationItem(item) ⇒ Object
Add one explanation item to the list of explanation items
115 116 117 |
# File 'lib/propolize.rb', line 115 def addExplanationItem(item) @explanationItems.push(item) end |
#dump(indent) ⇒ Object
Dump to stdout (for debugging/tracing)
120 121 122 123 124 125 |
# File 'lib/propolize.rb', line 120 def dump(indent) puts ("#{indent}#{@proposition}") for item in @explanationItems do puts ("#{indent} #{item}") end end |
#toHtml ⇒ Object
Output as HTML (Each proposition is one item in a list of propositions, so it is output as a <li> item.)
128 129 130 |
# File 'lib/propolize.rb', line 128 def toHtml return "<li>\n#{@proposition.toHtml}\n#{@explanationItems.map(&:toHtml).join("\n")}\n</li>" end |