Skip to content

Add SubdivisionContainment  #181

@quorak

Description

@quorak

Hey there, thanks for this great plugin. Just cam across the use case to need to subdivisionContainment. Easy access through the gem would be great.

e.g.:

module Cldr
  module Export
    module Data
      class SubdivisionsContainment < Base
        def initialize(*)
          super(nil)
          update(subdivision_containment: subdivision_containment)
        end

        def subdivision_containment
          @subdivision_containment ||= doc.xpath("supplementalData/subdivisionContainment/subgroup").each_with_object(
            Hash.new { |h, k| h[k] = { contains: [] } }
          ) do |territory, memo|
            territory_id = territory.attribute("type").value
            children = territory.attribute("contains").value.split(" ")

            memo[territory_id][:contains].concat(children)
            memo[territory_id][:contains].sort!
          end
        end
      end
    end
  end
end 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions