class ZphumzaFirstGem::Employee
Attributes
department[R]
first_name[R]
last_name[R]
name[R]
salary[R]
title[R]
Public Class Methods
all()
click to toggle source
# File lib/zphumza_first_gem.rb, line 18 def self.all ruby_data = [] Unirest.get('https://data.cityofchicago.org/resource/tt4n-kn4t.json').body.each do |employee| ruby_data << Employee.new(employee) end ruby_data end
department(parameter_option)
click to toggle source
# File lib/zphumza_first_gem.rb, line 26 def self.department(parameter_option) ruby_data = [] data = Unirest.get('https://data.cityofchicago.org/resource/tt4n-kn4t.json?department=#{parameter_option}').body data.each do |employee| ruby_data << Employee.new(employee) end ruby_data end
highest_paid(int: 3)
click to toggle source
# File lib/zphumza_first_gem.rb, line 35 def self.highest_paid(int: 3) ruby_data = [] Unirest.get('https://data.cityofchicago.org/resource/tt4n-kn4t.json').body.each do |employee| ruby_data << Employee.new(employee) end ruby_data.max_by(int) {|employee| employee.salary } end
new(input_options)
click to toggle source
# File lib/zphumza_first_gem.rb, line 9 def initialize(input_options) @title = input_options["job_titles"] @department = input_options['department'] @name = input_options['name'].to_s @salary = input_options['employee_annual_salary'].to_i @first_name = @name.split(", ")[1] @last_name = @name.split(", ")[0] end