Class: Bindery::Division

Inherits:
Object
  • Object
show all
Includes:
ContentMethods
Defined in:
lib/bindery/division.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ContentMethods

#appendix, #chapter, #div, #part, #section

Constructor Details

#initialize(div_type, title, file, options) ⇒ Division

Returns a new instance of Division.



10
11
12
13
14
15
# File 'lib/bindery/division.rb', line 10

def initialize(div_type, title, file, options)
  self.div_type = div_type
  self.title = title
  self.file = file
  self.options = options
end

Instance Attribute Details

#div_typeObject

Returns the value of attribute div_type.



3
4
5
# File 'lib/bindery/division.rb', line 3

def div_type
  @div_type
end

#fileObject

Returns the value of attribute file.



4
5
6
# File 'lib/bindery/division.rb', line 4

def file
  @file
end

#optionsObject

Returns the value of attribute options.



6
7
8
# File 'lib/bindery/division.rb', line 6

def options
  @options
end

#titleObject

Returns the value of attribute title.



5
6
7
# File 'lib/bindery/division.rb', line 5

def title
  @title
end

Instance Method Details

#body_only?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/bindery/division.rb', line 35

def body_only?
  options.fetch(:body_only, true)
end

#divisionsObject



31
32
33
# File 'lib/bindery/division.rb', line 31

def divisions
  @divisions ||= []
end

#include_images?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/bindery/division.rb', line 39

def include_images?
  options.fetch(:include_images, true)
end

#valid?Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/bindery/division.rb', line 17

def valid?
  true
  # ??? title specified? Is this required by the spec? Think about
  #   in what sense a chapter needs a title. Wouldn't it be nice
  #   if (say) Pratchett's books could be broken up a bit even
  #   though he doesn't have titled chapters? Aren't there books
  #   with actual chapters but no titles? Does epub provide
  #   another way to provide subdivisions without separate
  #   chapters that would break up the text flow?
  # file exists, readable
  # file content properly formed?  Does that matter?  Can we
  #   verify it? 
end