Sha256: 6744e968d1f7d108d50065257d4e1302b11d95cc3fd566f9814b0fe06203f58e
Contents?: true
Size: 783 Bytes
Versions: 32
Compression:
Stored size: 783 Bytes
Contents
class Chef module ChefFS class Parallelizer class FlattenEnumerable include Enumerable def initialize(enum, levels = nil) @enum = enum @levels = levels end attr_reader :enum attr_reader :levels def each(&block) enum.each do |value| flatten(value, levels, &block) end end private def flatten(value, levels, &block) if levels != 0 && value.respond_to?(:each) && !value.is_a?(String) value.each do |child| flatten(child, levels.nil? ? levels : levels - 1, &block) end else yield(value) end end end end end end
Version data entries
32 entries across 32 versions & 1 rubygems