Skip to content

Instantly share code, notes, and snippets.

@vzaremba
Last active December 22, 2015 09:19
Show Gist options
  • Save vzaremba/6451230 to your computer and use it in GitHub Desktop.
Save vzaremba/6451230 to your computer and use it in GitHub Desktop.
require 'ostruct'
class LastPayReport
def initialize employees
@employees = employees
end
def get_rows
rows = []
@employees.each do |employee|
employee.compensations.last_two
row = OpenStruct.new
row.full_name = employee.full_name
row.department = employee.department.nil? ? "" : employee.department.name
row.job_title = employee.job_title.nil? ? "" : employee.job_title.name
row.previous_pay = employee.compensations.last_two[1].nil? ? "" : employee.compensations.last_two[1].pay_rate.to_s << "/" << employee.compensations.last_two[1].pay_type.to_s
row.current_pay = employee.compensations.last_two[0].nil? ? "" : employee.compensations.last_two[0].pay_rate.to_s << "/" << employee.compensations.last_two[0].pay_type.to_s
row.change_date = employee.compensations.last_two[1].nil? ? "" : employee.compensations.last_two[0].date
rows << row
end
rows
end
end
@vsizov
Copy link

vsizov commented Sep 5, 2013

and so on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment