Class: ClockworkComicPDF::Book

Inherits:
Object
  • Object
show all
Includes:
BookInit, BookValidation, OptionValidation
Defined in:
lib/clockwork_comic_pdf/book.rb

Overview

variable storage for the book class

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from OptionValidation

#check_options, #check_required

Methods included from BookValidation

#get_comic_files, #image_mismatch, #scan_section, #scan_version, #section_files, #validate, #version_files

Methods included from BookInit

#initialize, #valid_options

Instance Attribute Details

#base_file_nameObject

Returns the value of attribute base_file_name.



27
28
29
# File 'lib/clockwork_comic_pdf/book.rb', line 27

def base_file_name
  @base_file_name
end

#coverObject

Returns the value of attribute cover.



93
94
95
# File 'lib/clockwork_comic_pdf/book.rb', line 93

def cover
  @cover
end

#fontObject



14
15
16
# File 'lib/clockwork_comic_pdf/book.rb', line 14

def font
  @font ||= 'Helvetica'
end

#page_headerObject

Returns the value of attribute page_header.



92
93
94
# File 'lib/clockwork_comic_pdf/book.rb', line 92

def page_header
  @page_header
end


87
88
89
90
# File 'lib/clockwork_comic_pdf/book.rb', line 87

def print_pagenum
  @print_pagenum = true if @print_toc.nil?
  @print_pagenum
end


81
82
83
84
# File 'lib/clockwork_comic_pdf/book.rb', line 81

def print_toc
  @print_toc = true if @print_toc.nil?
  @print_toc
end

#sectionsObject

Returns the value of attribute sections.



100
101
102
# File 'lib/clockwork_comic_pdf/book.rb', line 100

def sections
  @sections
end

#versionsObject



95
96
97
# File 'lib/clockwork_comic_pdf/book.rb', line 95

def versions
  @versions ||= []
end

Instance Method Details

#font_sizeObject



19
20
21
# File 'lib/clockwork_comic_pdf/book.rb', line 19

def font_size
  @font_size ||= 12
end

#font_size=(font_size) ⇒ Object



23
24
25
# File 'lib/clockwork_comic_pdf/book.rb', line 23

def font_size=(font_size)
  @font_size = font_size.to_points unless font_size.nil?
end

#infoObject



29
30
31
# File 'lib/clockwork_comic_pdf/book.rb', line 29

def info
  @info ||= {}
end

#info=(info) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/clockwork_comic_pdf/book.rb', line 33

def info=(info)
  if info.is_a? Hash
    info[:CreationDate] = Time.now
    info[:Creator] = 'Clockwork Comic PDF Engine'
    info[:Producer] = 'Prawn'
  else
    fail InvalidValueError, 'Information must be set as a Hash value'
  end
  @info = info
end

#marginObject



57
58
59
# File 'lib/clockwork_comic_pdf/book.rb', line 57

def margin
  @margin ||= { val: 0.25, type: :in }
end

#margin=(margin) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/clockwork_comic_pdf/book.rb', line 61

def margin=(margin)
  @margin = []
  margin = [margin] unless margin.is_a? Array
  unless margin.count == 4 || margin.count == 1
    fail InvalidValueError 'Margin must contain 1 or 4 values'
  end
  margin.each_index do |i|
    @margin[i] = margin[i].to_points
  end
  @margin
end

#offset_from_spineObject



73
74
75
# File 'lib/clockwork_comic_pdf/book.rb', line 73

def offset_from_spine
  @offset_from_spine ||= 0
end

#offset_from_spine=(offset_from_spine) ⇒ Object



77
78
79
# File 'lib/clockwork_comic_pdf/book.rb', line 77

def offset_from_spine=(offset_from_spine)
  @offset_from_spine = offset_from_spine.to_points
end

#page_sizeObject



44
45
46
47
# File 'lib/clockwork_comic_pdf/book.rb', line 44

def page_size
  @page_size ||= [{ val: 8.5, type: :in },
                  { val: 11, type: :in }]
end

#page_size=(page_size) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/clockwork_comic_pdf/book.rb', line 49

def page_size=(page_size)
  page_size = page_size.to_a
  page_size.each do |dim|
    page_size[page_size.find_index dim] = dim.to_points
  end
  @page_size = page_size
end