Class: ClockworkComicPDF::Version

Inherits:
Object
  • Object
show all
Includes:
OptionValidation
Defined in:
lib/clockwork_comic_pdf/version.rb

Overview

stores version information for PDF generation includes name, length, dpi and a toggle for printing the cover

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from OptionValidation

#check_options, #check_required

Constructor Details

#initialize(options = {}) ⇒ Version

Returns a new instance of Version.



51
52
53
54
55
56
57
# File 'lib/clockwork_comic_pdf/version.rb', line 51

def initialize(options = {})
  check_options(options.keys, [:name, :dpi, :print_cover, :trim_offset])
  self.name = options[:name]
  self.dpi = options[:dpi]
  self.trim_offset = options[:trim_offset]
  self.print_cover = options[:print_cover]
end

Instance Attribute Details

#dpiObject

Returns the value of attribute dpi.



26
27
28
# File 'lib/clockwork_comic_pdf/version.rb', line 26

def dpi
  @dpi
end

#nameObject

Returns the value of attribute name.



21
22
23
# File 'lib/clockwork_comic_pdf/version.rb', line 21

def name
  @name
end


31
32
33
34
# File 'lib/clockwork_comic_pdf/version.rb', line 31

def print_cover
  @print_cover = false if @print_cover.nil?
  @print_cover
end

#trim_offsetObject



37
38
39
40
# File 'lib/clockwork_comic_pdf/version.rb', line 37

def trim_offset
  @trim_offset = false if @trim_offset.nil?
  @trim_offset
end

Instance Method Details

#validateObject



43
44
45
46
47
48
49
# File 'lib/clockwork_comic_pdf/version.rb', line 43

def validate
  fail InvalidValueError, 'Each version must contain a name' unless name
  fail InvalidValueError,
       'Each version must contain a name' if name.length == 0
  fail InvalidValueError,
       'each version must specify a dpi value' unless dpi
end