Class: ODDB::Text::Chapter
- Inherits:
-
Object
- Object
- ODDB::Text::Chapter
- Defined in:
- lib/oddb/text/chapter.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#paragraphs ⇒ Object
readonly
Returns the value of attribute paragraphs.
Instance Method Summary collapse
- #add_paragraph(paragraph) ⇒ Object
- #append(chapter) ⇒ Object
-
#initialize(name) ⇒ Chapter
constructor
A new instance of Chapter.
- #to_s ⇒ Object
Constructor Details
#initialize(name) ⇒ Chapter
Returns a new instance of Chapter.
12 13 14 15 |
# File 'lib/oddb/text/chapter.rb', line 12 def initialize(name) @name = name @paragraphs = [] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/oddb/text/chapter.rb', line 11 def name @name end |
#paragraphs ⇒ Object (readonly)
Returns the value of attribute paragraphs.
11 12 13 |
# File 'lib/oddb/text/chapter.rb', line 11 def paragraphs @paragraphs end |
Instance Method Details
#add_paragraph(paragraph) ⇒ Object
16 17 18 |
# File 'lib/oddb/text/chapter.rb', line 16 def add_paragraph(paragraph) @paragraphs.push paragraph unless paragraph.empty? end |
#append(chapter) ⇒ Object
19 20 21 |
# File 'lib/oddb/text/chapter.rb', line 19 def append(chapter) @paragraphs.concat chapter.paragraphs end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/oddb/text/chapter.rb', line 22 def to_s @paragraphs.join("\n") end |