lib/tianming_shopicruit/shopicruit.rb
# array of symbols => float
# Returns the sum of the prices of all product variants of the types specified in product_types
array of symbols => float
Returns the sum of the prices of all product variants of the types specified in product_types
array of symbols = > float Returns the sum of the prices of all product variants of the types specified in product_types
def calc_total_price(product_types)
    products_prices = @products.map do |product|
      current_product_type = product['product_type']
      if product_types.include? current_product_type.downcase.to_sym
        variants =  product['variants']
        calc_variants_prices_sum(variants)
      else
        0
      end
    end
    products_prices.reduce(&:+).round 2
  end
def calc_total_price ( product_types ) products_prices = @products . map do | product | current_product_type = product [ 'product_type' ] if product_types . include? current_product_type . downcase . to_sym variants = product [ 'variants' ] calc_variants_prices_sum ( variants ) else 0 end end products_prices . reduce ( & :+ ) . round 2 end
array of symbols => float
Returns the sum of the prices of all product variants of the types specified in product_types
array of symbols = > float Returns the sum of the prices of all product variants of the types specified in product_types
product_types
<not_specific>