Sha256: edb42ca031d07f1da2d5efac29cf8222c5a87ba828ae183e58b0efb3a11c68e7
Contents?: true
Size: 397 Bytes
Versions: 9
Compression:
Stored size: 397 Bytes
Contents
# frozen_string_literal: true module Peddler # @api private class StructuredList def initialize(*keys) @keys = keys end def build(vals) Array(vals) .flatten .each_with_index .reduce({}) { |hsh, (v, i)| hsh.merge(compose_key(i + 1) => v) } end private def compose_key(index) (@keys.dup << index).join('.') end end end
Version data entries
9 entries across 9 versions & 1 rubygems