Class: Ebookie::Document::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ebookie/document/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title) ⇒ Base

Returns a new instance of Base.



7
8
9
10
11
12
13
# File 'lib/ebookie/document/base.rb', line 7

def initialize(title)
  @chapters = []
  @images = []

  @config = Config.new
  @config.title = title
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/ebookie/document/base.rb', line 39

def method_missing(meth, *args)
  if @config.respond_to?(meth)
    @config.send(meth, *args)
  else
    super
  end
end

Instance Attribute Details

#chaptersObject (readonly)

Returns the value of attribute chapters.



5
6
7
# File 'lib/ebookie/document/base.rb', line 5

def chapters
  @chapters
end

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/ebookie/document/base.rb', line 5

def config
  @config
end

#imagesObject (readonly)

Returns the value of attribute images.



5
6
7
# File 'lib/ebookie/document/base.rb', line 5

def images
  @images
end

Instance Method Details

#chapter(title, content) ⇒ Object



19
20
21
# File 'lib/ebookie/document/base.rb', line 19

def chapter(title, content)
  @chapters << Chapter.new(title, content)
end

#configure {|@config| ... } ⇒ Object

Yields:



15
16
17
# File 'lib/ebookie/document/base.rb', line 15

def configure(&block)
  yield @config
end

#image(file) ⇒ Object



23
24
25
# File 'lib/ebookie/document/base.rb', line 23

def image(file)
  @images << Image.new(file)
end

#render_epubObject



31
32
33
# File 'lib/ebookie/document/base.rb', line 31

def render_epub
  Rendering::Epub.new(self).render
end

#render_mobiObject



35
36
37
# File 'lib/ebookie/document/base.rb', line 35

def render_mobi
  Rendering::Mobi.new(self).render
end

#render_pdfObject



27
28
29
# File 'lib/ebookie/document/base.rb', line 27

def render_pdf
  Rendering::Pdf.new(self).render
end