Class: ReVIEW::Book::Part
- Includes:
- Compilable
- Defined in:
- lib/review/book/part.rb
Instance Attribute Summary collapse
-
#chapters ⇒ Object
readonly
Returns the value of attribute chapters.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
Attributes included from Compilable
Instance Method Summary collapse
- #each_chapter(&block) ⇒ Object
- #file? ⇒ Boolean
- #format_number(heading = true) ⇒ Object
-
#initialize(book, number, chapters, name = '', io = nil) ⇒ Part
constructor
if Part is dummy, ‘number` is nil.
- #on_appendix? ⇒ Boolean (also: #on_APPENDIX?)
- #volume ⇒ Object
Methods included from Compilable
#basename, #bibpaper, #bibpaper_index, #column, #column_index, #dirname, #equation, #equation_index, #footnote, #footnote_index, #headline, #headline_index, #icon_index, #image, #image_index, #indepimage_index, #lines, #list, #list_index, #next_chapter, #numberless_image_index, #prev_chapter, #size, #table, #table_index, #title
Methods included from TextUtils
Constructor Details
#initialize(book, number, chapters, name = '', io = nil) ⇒ Part
if Part is dummy, ‘number` is nil.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/review/book/part.rb', line 18 def initialize(book, number, chapters, name = '', io = nil) @book = book @number = number @chapters = chapters @name = name @path = name @content = nil if io @content = io.read elsif @path.present? && File.exist?(File.join(@book.config['contentdir'], @path)) @content = File.read(File.join(@book.config['contentdir'], @path), mode: 'r:BOM|utf-8') @name = File.basename(@name, '.re') end if file? @title = nil else @title = name end @volume = nil end |
Instance Attribute Details
#chapters ⇒ Object (readonly)
Returns the value of attribute chapters.
40 41 42 |
# File 'lib/review/book/part.rb', line 40 def chapters @chapters end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
41 42 43 |
# File 'lib/review/book/part.rb', line 41 def name @name end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
39 40 41 |
# File 'lib/review/book/part.rb', line 39 def number @number end |
Instance Method Details
#each_chapter(&block) ⇒ Object
43 44 45 |
# File 'lib/review/book/part.rb', line 43 def each_chapter(&block) @chapters.each(&block) end |
#file? ⇒ Boolean
53 54 55 |
# File 'lib/review/book/part.rb', line 53 def file? name.present? and path.end_with?('.re') end |
#format_number(heading = true) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/review/book/part.rb', line 57 def format_number(heading = true) if heading I18n.t('part', @number) else @number.to_s end end |
#on_appendix? ⇒ Boolean Also known as: on_APPENDIX?
65 66 67 |
# File 'lib/review/book/part.rb', line 65 def on_appendix? false end |