Class: ODDB::Text::Chapter

Inherits:
Object
  • Object
show all
Defined in:
lib/oddb/text/chapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/oddb/text/chapter.rb', line 11

def name
  @name
end

#paragraphsObject (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_sObject



22
23
24
# File 'lib/oddb/text/chapter.rb', line 22

def to_s
  @paragraphs.join("\n")
end