Class: AudioBookCreator::Defaulter
- Inherits:
-
Object
- Object
- AudioBookCreator::Defaulter
- Extended by:
- Forwardable
- Defined in:
- lib/audio_book_creator/defaulter.rb
Constant Summary collapse
- ATTRIBUTES =
[:title_path, :body_path, :link_path, :chapter_path]
Instance Attribute Summary collapse
-
#book_def ⇒ Object
Returns the value of attribute book_def.
-
#page_def ⇒ Object
Returns the value of attribute page_def.
- #settings ⇒ Object
Instance Method Summary collapse
- #host ⇒ Object
-
#initialize(page_def, book_def) ⇒ Defaulter
constructor
A new instance of Defaulter.
- #load_unset_values ⇒ Object
- #store ⇒ Object
Constructor Details
#initialize(page_def, book_def) ⇒ Defaulter
Returns a new instance of Defaulter.
13 14 15 16 |
# File 'lib/audio_book_creator/defaulter.rb', line 13 def initialize(page_def, book_def) @page_def = page_def @book_def = book_def end |
Instance Attribute Details
#book_def ⇒ Object
Returns the value of attribute book_def.
10 11 12 |
# File 'lib/audio_book_creator/defaulter.rb', line 10 def book_def @book_def end |
#page_def ⇒ Object
Returns the value of attribute page_def.
9 10 11 |
# File 'lib/audio_book_creator/defaulter.rb', line 9 def page_def @page_def end |
#settings ⇒ Object
23 24 25 26 |
# File 'lib/audio_book_creator/defaulter.rb', line 23 def settings # in the future, move into pages @settings ||= PageDb.new("settings.db", "settings", true) end |
Instance Method Details
#host ⇒ Object
18 19 20 21 |
# File 'lib/audio_book_creator/defaulter.rb', line 18 def host url = book_def.urls.first url && URI.parse(url).host end |
#load_unset_values ⇒ Object
28 29 30 31 |
# File 'lib/audio_book_creator/defaulter.rb', line 28 def load_unset_values value = host && settings[host] value.each { |n, v| public_send("#{n}=", v) } if value end |
#store ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/audio_book_creator/defaulter.rb', line 33 def store return unless host settings[host] = ATTRIBUTES.each_with_object(settings[host] || {}) do |attr, h| v = public_send(attr) h[attr] = v if v end end |