Last active
August 29, 2015 14:15
-
-
Save guilleiguaran/d6637b98f64691fbdba5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def salaries_by_lang(salaries, lang) | |
salaries.find_all{|x| x[:in_what_technologies_are_you_proficient?] =~ /#{lang}/} | |
end | |
# company_type can be for example: multinational, outside, exclusively | |
def salaries_by_company_type(salaries, company_type) | |
salaries.find_all{|x| x[:"referring_to_the_company_or_project_that_you_work_for_most_of_the_time:"] =~ /#{company_type}/} | |
end | |
def group_by_salary(collection) | |
collection.group_by{|x| x[:"excluding_equity,_how_much_money_do_you_earn_on_a_monthly_basis?"]} | |
end | |
def print_groups_count(groups) | |
groups.each{|k,v| puts "#{k}: #{v.count}"} | |
end | |
def print_salary_info(salaries, title) | |
puts "=========================" | |
puts "#{title} salaries" | |
puts "Total: #{salaries.size}" | |
groups = group_by_salary(salaries) | |
print_groups_count(groups) | |
end | |
salaries = SmarterCSV.process('salary_survey_colombians_2015.csv') | |
salaries_for_lang = salaries_by_lang(salaries, "Ruby") | |
puts "Total salaries: #{salaries_for_lang.size}" | |
multinational_salaries = salaries_by_company_type(salaries_for_lang, "multinational") | |
outside_salaries = salaries_by_company_type(salaries_for_lang, "outside") | |
colombia_salaries = salaries_by_company_type(salaries_for_lang, "exclusively") | |
print_salary_info(colombia_salaries, "Colombia") | |
print_salary_info(multinational_salaries, "Multinational") | |
print_salary_info(outside_salaries, "Outside") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment