Class: AudioBookCreator::Chapter
- Inherits:
-
Object
- Object
- AudioBookCreator::Chapter
- Defined in:
- lib/audio_book_creator/chapter.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#number ⇒ Object
Returns the value of attribute number.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #empty? ⇒ Boolean
- #filename ⇒ Object
-
#initialize(options = {}) ⇒ Chapter
constructor
A new instance of Chapter.
- #present? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Chapter
5 6 7 8 |
# File 'lib/audio_book_creator/chapter.rb', line 5 def initialize( = {}) .each { |n, v| public_send("#{n}=", v) } @body = Array(body).compact.join("\n\n") end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
3 4 5 |
# File 'lib/audio_book_creator/chapter.rb', line 3 def body @body end |
#number ⇒ Object
Returns the value of attribute number.
3 4 5 |
# File 'lib/audio_book_creator/chapter.rb', line 3 def number @number end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/audio_book_creator/chapter.rb', line 3 def title @title end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
26 27 28 29 30 |
# File 'lib/audio_book_creator/chapter.rb', line 26 def ==(other) other.kind_of?(Chapter) && other.number == number && other.title.eql?(title) && other.body.eql?(body) end |
#empty? ⇒ Boolean
14 15 16 |
# File 'lib/audio_book_creator/chapter.rb', line 14 def empty? body.empty? end |
#filename ⇒ Object
10 11 12 |
# File 'lib/audio_book_creator/chapter.rb', line 10 def filename format("chapter%02d", number) end |
#present? ⇒ Boolean
18 19 20 |
# File 'lib/audio_book_creator/chapter.rb', line 18 def present? !empty? end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/audio_book_creator/chapter.rb', line 22 def to_s "#{title}\n\n#{body}\n" end |