class Datasets::CLDRPlurals::Listener

Spec: unicode.org/reports/tr35/tr35-numbers.html#Language_Plural_Rules

Public Class Methods

new(abort_tag, &block) click to toggle source
# File lib/datasets/cldr-plurals.rb, line 57
def initialize(abort_tag, &block)
  @abort_tag = abort_tag
  @block = block
  @tag_name_stack = []
end

Public Instance Methods

tag_end(name) click to toggle source
# File lib/datasets/cldr-plurals.rb, line 74
def tag_end(name)
  case name
  when "pluralRules"
    @locales.each do |locale_name|
      @block.call(Locale.new(locale_name, @rules))
    end
  when "pluralRule"
    @rules << @rule
  end
  @tag_name_stack.pop
end
tag_start(name, attributes) click to toggle source
# File lib/datasets/cldr-plurals.rb, line 63
def tag_start(name, attributes)
  @tag_name_stack.push(name)
  case name
  when "pluralRules"
    @locales = attributes["locales"].split
    @rules = []
  when "pluralRule"
    @rule = Rule.new(attributes["count"])
  end
end
text(data) click to toggle source
# File lib/datasets/cldr-plurals.rb, line 86
def text(data)
  case @tag_name_stack.last
  when "pluralRule"
    parse_plural_rule(data)
  end
end

Private Instance Methods

parse_plural_rule(data) click to toggle source
# File lib/datasets/cldr-plurals.rb, line 94
def parse_plural_rule(data)
  parser = RuleParser.new(@rule, data)
  parser.parse
end