Class: Slaw::Grammars::Counters

Inherits:
Object
  • Object
show all
Defined in:
lib/slaw/grammars/counters.rb

Constant Summary collapse

@@counters =

Counters for generating element IDs. This is a hash from the element ID prefix, to another hash that maps the element type name to a count.

For backwards compatibility, counters always start at -1, and must be incremented before being used. This ensures that element ids start at 0. This is NOT compatible with AKN 3.0 which requires that element numbers start at 1.

eg.

section-1 => paragraph => 2
Hash.new{ |h, k| h[k] = Hash.new(-1) }

Class Method Summary collapse

Class Method Details

.countersObject



18
19
20
# File 'lib/slaw/grammars/counters.rb', line 18

def self.counters
  @@counters
end

.reset!Object



22
23
24
# File 'lib/slaw/grammars/counters.rb', line 22

def self.reset!
  @@counters.clear
end