Class: EmployeeParser

Inherits:
BaseParser show all
Defined in:
lib/bob/parsers/employee_parser.rb

Instance Attribute Summary

Attributes inherited from BaseParser

#json_response

Instance Method Summary collapse

Methods inherited from BaseParser

#fields, #initialize

Constructor Details

This class inherits a constructor from BaseParser

Instance Method Details

#employeeObject



4
5
6
# File 'lib/bob/parsers/employee_parser.rb', line 4

def employee
  Models::Employee.new(json_response)
end

#employeesObject



8
9
10
# File 'lib/bob/parsers/employee_parser.rb', line 8

def employees
  json_response['employees'].map { |attributes| Models::Employee.new(attributes) }
end

#managersObject



12
13
14
15
16
# File 'lib/bob/parsers/employee_parser.rb', line 12

def managers
  json_response['employees']
    .select { |employee| employee['work']['isManager'] }
    .map { |attributes| Models::Employee.new(attributes) }
end

#starters_on(date) ⇒ Object



18
19
20
21
22
# File 'lib/bob/parsers/employee_parser.rb', line 18

def starters_on(date)
  json_response['employees']
    .select { |employee| Date.parse(employee['work']['startDate']) == date }
    .map { |attributes| Models::Employee.new(attributes) }
end