Class: MakeBook::Build

Inherits:
Object
  • Object
show all
Defined in:
lib/makebook/build.rb

Overview

Build context

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(out: nil) ⇒ Build

Returns a new instance of Build.



5
6
7
# File 'lib/makebook/build.rb', line 5

def initialize(out: nil)
  @root = Pathname.new(out || MakeBook::Build.default_root)
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



3
4
5
# File 'lib/makebook/build.rb', line 3

def root
  @root
end

Class Method Details

.default_rootObject



24
25
26
# File 'lib/makebook/build.rb', line 24

def default_root
  Pathname.pwd + 'out'
end

Instance Method Details

#build(book) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/makebook/build.rb', line 9

def build(book)
  b = MakeBook::Book.new(book)
  b.formats.each do |format|
    format, options = format.first if format.is_a? Hash
    options ||= {}

    case format
    when 'html' then MakeBook::Formats::HTML.new(b, self, options).make
    when 'pdf' then MakeBook::Formats::PDF.new(b, self, options).make
    else raise NotImplementedError, format
    end
  end
end