Class: Kitchen::Directions::BakePreface::V1

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/directions/bake_preface/v1.rb

Instance Method Summary collapse

Instance Method Details

#bake(book:, title_element:) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/kitchen/directions/bake_preface/v1.rb', line 5

def bake(book:, title_element:)
  book.pages('$.preface').each do |page|
    page.search('div[data-type="description"], div[data-type="abstract"]').each(&:trash)
    page.titles.each do |title|
      title.replace_children(with:
        <<~HTML
          <span data-type="" itemprop="" class="os-text">#{title.text}</span>
        HTML
      )
      title.name = title_element
    end
  end
end