lib/crontab_expression.rb
# Return the cartesian product of the given parts as merged hashes.
#
# parts - a hash of the time parts to combine
#
# Example:
#
#   merged_product(:m => [0,30], :h => [8,16]) # => [
#     {:m => 0, :h => 8}
#     {:m => 0, :h => 16}
#     {:m => 30, :h => 8}
#     {:m => 30, :h => 16}
#   ]
#
# Returns an array of the merged/combined parts
Return the cartesian product of the given parts as merged hashes.
parts - a hash of the time parts to combine





Returns an array of the merged/combined parts
Return the cartesian product of the given parts as merged hashes . parts - a hash of the time parts to combine Returns an array of the merged / combined parts
def merged_product(parts)
    result = []
    parts.map do |key, values|
      if result.empty?
        values.each { |v| result << {key => v} }
      else
        combined = []
        result.each do |r|
          values.each do |v|
            combined << r.merge(key => v)
          end
        end
        result = combined
      end
    end
    result
  end
def merged_product ( parts ) result = [ ] parts . map do | key , values | if result . empty? values . each { | v | result << { key => v } } else combined = [ ] result . each do | r | values . each do | v | combined << r . merge ( key => v ) end end result = combined end end result end
Return the cartesian product of the given parts as merged hashes.
Return the cartesian product of the given parts as merged hashes .
parts