Class: Datasets::CLDRPlurals

Inherits:
Dataset
  • Object
show all
Defined in:
lib/datasets/cldr-plurals.rb

Defined Under Namespace

Classes: Locale, Rule

Instance Attribute Summary

Attributes inherited from Dataset

#metadata

Instance Method Summary collapse

Methods inherited from Dataset

#clear_cache!, #to_table

Constructor Details

#initializeCLDRPlurals

Returns a new instance of CLDRPlurals.



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/datasets/cldr-plurals.rb', line 18

def initialize
  super()
  @metadata.id = "cldr-plurals"
  @metadata.name = "CLDR language plural rules"
  @metadata.url = "https://raw.githubusercontent.com/unicode-org/cldr/master/common/supplemental/plurals.xml"
  @metadata.licenses = ["Unicode-DFS-2016"]
  @metadata.description = <<~DESCRIPTION
    Language plural rules in Unicode Common Locale Data Repository.
    See also: https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_plural_rules.html
  DESCRIPTION
end

Instance Method Details

#each(&block) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/datasets/cldr-plurals.rb', line 30

def each(&block)
  return to_enum(__method__) unless block_given?

  open_data do |input|
    catch do |abort_tag|
      listener = Listener.new(abort_tag, &block)
      parser = REXML::Parsers::StreamParser.new(input, listener)
      parser.parse
    end
  end
end