Class: Typedown::Section
- Inherits:
-
String
- Object
- String
- Typedown::Section
- Defined in:
- lib/typedown/section.rb
Class Method Summary collapse
Instance Method Summary collapse
- #body ⇒ Object
- #doc ⇒ Object
- #dummy? ⇒ Boolean
-
#initialize(title, body) ⇒ Section
constructor
A new instance of Section.
- #subsections ⇒ Object
- #title ⇒ Object
Constructor Details
Class Method Details
Instance Method Details
#body ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/typedown/section.rb', line 22 def body b = Document.new(@body || "") b << "\n\n" subsections.each do |s| b << s.doc end b end |
#doc ⇒ Object
31 32 33 34 35 36 |
# File 'lib/typedown/section.rb', line 31 def doc d = Document.new "! #{title}\n\n" #raise d.encoding.name + "/" + body.valid_encoding? d << body.gsub(/^(!+ )/, '!\0') d end |
#dummy? ⇒ Boolean
14 15 16 |
# File 'lib/typedown/section.rb', line 14 def dummy? subsections.length == 1 && (title.strip.empty? || title.tr("!","").strip == subsections[0].title.tr("!","").strip) && (!@body || @body.strip.empty?) end |
#subsections ⇒ Object
38 39 40 |
# File 'lib/typedown/section.rb', line 38 def subsections @sections || [] end |
#title ⇒ Object
18 19 20 |
# File 'lib/typedown/section.rb', line 18 def title @title || "" end |