Sha256: c65e305854c90c6c9b6bbd2cd5ea9ab1cbea4237dc7bfe638663fcc710d89b89
Contents?: true
Size: 355 Bytes
Versions: 15
Compression:
Stored size: 355 Bytes
Contents
module Peddler # @api private class StructuredList def initialize(*keys) @keys = keys end def build(vals) Array(vals) .each_with_index .reduce(Hash.new) { |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
15 entries across 15 versions & 1 rubygems