Class: Bamboozled::API::FieldCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/bamboozled/api/field_collection.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fields) ⇒ FieldCollection

Returns a new instance of FieldCollection.



88
89
90
# File 'lib/bamboozled/api/field_collection.rb', line 88

def initialize(fields)
  self.fields = fields || []
end

Class Method Details

.all_namesObject

rubocop:disable Metrics/MethodLength



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/bamboozled/api/field_collection.rb', line 10

def self.all_names # rubocop:disable Metrics/MethodLength
  %w[
    address1
    address2
    age
    bestEmail
    birthday
    bonusAmount
    bonusComment
    bonusDate
    bonusReason
    city
    commisionDate
    commissionAmount
    commissionComment
    commissionDate
    country
    dateOfBirth
    department
    displayName
    division
    eeo
    employeeNumber
    employmentHistoryStatus
    ethnicity
    exempt
    firstName
    flsaCode
    fullName1
    fullName2
    fullName3
    fullName4
    fullName5
    gender
    hireDate
    homeEmail
    homePhone
    id
    includeInPayroll
    isPhotoUploaded
    jobTitle
    lastChanged
    lastName
    location
    maritalStatus
    middleName
    mobilePhone
    originalHireDate
    paidPer
    payChangeReason
    payFrequency
    payGroup
    payGroupId
    payPer
    payRate
    payRateEffectiveDate
    paySchedule
    payScheduleId
    payType
    preferredName
    sin
    ssn
    standardHoursPerWeek
    state
    stateCode
    status
    supervisor
    supervisorEId
    supervisorId
    terminationDate
    workEmail
    workPhone
    workPhoneExtension
    workPhonePlusExtension
    zipcode
  ]
end

.wrap(fields) ⇒ Object



4
5
6
7
8
# File 'lib/bamboozled/api/field_collection.rb', line 4

def self.wrap(fields)
  fields = all_names if fields == :all
  fields = fields.split(",") if fields.is_a?(String)
  new(fields)
end

Instance Method Details

#to_csvObject



92
93
94
# File 'lib/bamboozled/api/field_collection.rb', line 92

def to_csv
  fields.join(",")
end

#to_xmlObject



96
97
98
99
100
# File 'lib/bamboozled/api/field_collection.rb', line 96

def to_xml
  "<fields>" +
    fields.map { |field| "<field id=\"#{field}\" />" }.join +
    "</fields>"
end