Sha256: a7e08a85404daf53bb0b374cf92de994fa0ac386333fd7cd5be45dc336c87f66

Contents?: true

Size: 950 Bytes

Versions: 1

Compression:

Stored size: 950 Bytes

Contents

# Page title management for page number generation
class DjVuNumberer < DjVuTools

  # @see ObjectName#method
  def initialize file
    super
    @sections = []
  end

  # Add a labeled section.
  # @param [Hash] section
  # @see file:README.rdoc The Numberer section in the README
  def add_section section

    if section[:start].nil?
      raise ArgumentError, 'Cannot label a range of pages with the same title' if ( section[:range].max - section[:range].min > 0 )
      section[:range].each { |n| @djvu.title_page n, section[:title]  }
    else
      section[:range].each_with_index do |n, i|
      number = section[:start] + i
      number =
        case section[:type]
        when :arabic
          number.to_s
        when :upper_roman
          RomanNumerals::to_roman(number).upcase
        when :lower_roman
          RomanNumerals::to_roman(number).downcase
        end
        @djvu.title_page n, "#{number}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
djvu-tools-0.0.1 lib/djvu-tools/djvu-numberer.rb