Sha256: 406c8a1a6aad7058db4a0100a0bd7b69a6ba278d61b703854b1b56de0c8d44b8
Contents?: true
Size: 938 Bytes
Versions: 4
Compression:
Stored size: 938 Bytes
Contents
require 'rubygems' require 'lib/parseitc' include ParseITC begin report = Parser.new('demo1.txt') report.add_file('demo2.txt') puts '=' * 20 puts "Sales in top 10 countries" report.count_by_country.sort_by{|k,v| v}.reverse[0..9].each do |k, v| puts " #{k}: #{v}" end puts puts '=' * 20 puts "Sales volume per day" report.count_by_date.sort.each do |k, v| puts " #{k}: #{v}" end puts puts '=' * 20 puts "Sales by price and date" total = 0 report.split_by_date.sort.each do |k1, v1| puts " #{k1}" v1.count_by_price_tier.sort.each do |k2, v2| dollars = ApplePricing[:usd][k2] puts " $ #{dollars.to_f}: #{v2}" total += dollars.to_f * v2 end end puts "Revenue: $#{total/7*10} " puts "Profit: $#{total} " rescue Errno::ENOENT puts "The data file you specified was not found" rescue Errno::EACCES puts "The data file you specified is not readable" end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
parseitc-0.1.6 | demo.rb |
parseitc-0.1.5 | demo.rb |
parseitc-0.1.4 | demo.rb |
parseitc-0.1.3 | demo.rb |