Class: AudioBookCreator::Editor

Inherits:
Object
  • Object
show all
Defined in:
lib/audio_book_creator/editor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page_def) ⇒ Editor

Returns a new instance of Editor.



6
7
8
# File 'lib/audio_book_creator/editor.rb', line 6

def initialize(page_def)
  @page_def = page_def
end

Instance Attribute Details

#page_defObject

Returns the value of attribute page_def.



4
5
6
# File 'lib/audio_book_creator/editor.rb', line 4

def page_def
  @page_def
end

Instance Method Details

#parse(pages) ⇒ Object

convert page[] -> chapter[]



11
12
13
14
15
16
17
# File 'lib/audio_book_creator/editor.rb', line 11

def parse(pages)
  pages.each_with_index.map do |page, i|
    title = page.css(page_def.title_path).first || "Chapter #{i + 1}"
    body = page.css(page_def.body_path)
    Chapter.new(number: (i + 1), title: title, body: body)
  end
end