Sha256: 34d3f61f915379386ac2fede3464c008591578e182fb5048bfd2d8afc896edb2

Contents?: true

Size: 1.08 KB

Versions: 14

Compression:

Stored size: 1.08 KB

Contents

require "roman-numerals"

module IsoDoc::Function
  module XrefGen
    def hiersep
      "."
    end

    def hierfigsep
      "-"
    end

    class Counter
      def initialize
        @num = 0
        @letter = ""
        @subseq = ""
      end

      def increment(node)
        return self if node["unnumbered"]
        if node["subsequence"] != @subseq
          @subseq = node["subsequence"]
          @num += 1
          @letter = node["subsequence"] ? "a" : ""
        else
          if @letter.empty?
            @num += 1
          else
            @letter = (@letter.ord + 1).chr.to_s
          end
        end
        self
      end

      def print
        "#{@num}#{@letter}"
      end

      def listlabel(depth)
        return @num.to_s if [2, 7].include? depth
        return (96 + @num).chr.to_s if [1, 6].include? depth
        return (64 + @num).chr.to_s if [4, 9].include? depth
        return RomanNumerals.to_roman(@num).downcase if [3, 8].include? depth
        return RomanNumerals.to_roman(@num).upcase if [5, 10].include? depth
        return @num.to_s
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
isodoc-1.0.28 lib/isodoc/function/xref_counter.rb
isodoc-1.0.27 lib/isodoc/function/xref_counter.rb
isodoc-1.0.26 lib/isodoc/function/xref_counter.rb
isodoc-1.0.25 lib/isodoc/function/xref_counter.rb
isodoc-1.0.24 lib/isodoc/function/xref_counter.rb
isodoc-1.0.23 lib/isodoc/function/xref_counter.rb
isodoc-1.0.22 lib/isodoc/function/xref_counter.rb
isodoc-1.0.21 lib/isodoc/function/xref_counter.rb
isodoc-1.0.20 lib/isodoc/function/xref_counter.rb
isodoc-1.0.19 lib/isodoc/function/xref_counter.rb
isodoc-1.0.18 lib/isodoc/function/xref_counter.rb
isodoc-1.0.17 lib/isodoc/function/xref_counter.rb
isodoc-1.0.16 lib/isodoc/function/xref_counter.rb
isodoc-1.0.15 lib/isodoc/function/xref_counter.rb