class ReVIEW::Book::Chapter

Attributes

book[R]
number[R]

Public Class Methods

new(book, number, name, path, io = nil) click to toggle source
# File ../../../../../lib/review/book/chapter.rb, line 23
def initialize(book, number, name, path, io = nil)
  @book = book
  @number = number
  @name = name
  @path = path
  @io = io
  @title = nil
  @content = nil
  @list_index = nil
  @table_index = nil
  @footnote_index = nil
  @image_index = nil
  @icon_index = nil
  @numberless_image_index = nil
  @indepimage_index = nil
  @headline_index = nil
  @column_index = nil
end

Public Instance Methods

format_number(heading = true) click to toggle source
# File ../../../../../lib/review/book/chapter.rb, line 46
def format_number(heading = true)
  if on_PREDEF?
    return "#{@number}"
  end

  if on_APPENDIX?
    return "#{@number}" if @number < 1 || @number > 27

    type = @book.config["appendix_format"].blank? ? "arabic" : @book.config["appendix_format"].downcase.strip
    appendix = case type
                 when "roman"
                   ROMAN[@number]
                 when "alphabet", "alpha"
                   ALPHA[@number]
                 else
                   # nil, "arabic", etc...
                   "#{@number}"
               end
    if heading
      return "#{I18n.t("appendix", appendix)}"
    else
      return "#{appendix}"
    end
  end

  if heading
    "#{I18n.t("chapter", @number)}"
  else
    "#{@number}"
  end
end
inspect() click to toggle source
# File ../../../../../lib/review/book/chapter.rb, line 42
def inspect
  "\#<#{self.class} #{@number} #{@path}>"
end
on_APPENDIX?() click to toggle source
# File ../../../../../lib/review/book/chapter.rb, line 86
def on_APPENDIX?
  on_FILE?(@book.read_APPENDIX)
end
on_CHAPS?() click to toggle source
# File ../../../../../lib/review/book/chapter.rb, line 78
def on_CHAPS?
  on_FILE?(@book.read_CHAPS)
end
on_POSTDEF?() click to toggle source
# File ../../../../../lib/review/book/chapter.rb, line 90
def on_POSTDEF?
  on_FILE?(@book.read_POSTDEF)
end
on_PREDEF?() click to toggle source
# File ../../../../../lib/review/book/chapter.rb, line 82
def on_PREDEF?
  on_FILE?(@book.read_PREDEF)
end
toc() click to toggle source
# File ../../../../../lib/review/tocparser.rb, line 339
def toc
  @toc ||= TOCParser.parse(self)
  unless @toc.size == 1
    $stderr.puts "warning: chapter #{@toc.join} contains more than 1 chapter"
  end
  @toc.first
end