osm 0.0.11 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,18 +10,33 @@ module Osm
10
10
  # @!attribute [r] permissions
11
11
  # @return [Hash] the permissions assigned to this API by the user in OSM
12
12
 
13
- # Initialize a new API Access using the hash returned by the API call
14
- # @param data the hash of data for the object returned by the API
15
- def initialize(data)
16
- @id = data['apiid'].to_i
17
- @name = data['name']
18
- @permissions = data['permissions'].is_a?(Hash) ? data['permissions'] : {}
13
+ # Initialize a new ApiAccess
14
+ # @param [Hash] attributes the hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
15
+ def initialize(attributes={})
16
+ raise ArgumentError, ':id must be a Fixnum > 0' unless (attributes[:id].is_a?(Fixnum) && attributes[:id] > 0)
17
+ raise ArgumentError, ':name must be a String' unless attributes[:name].is_a?(String)
18
+ raise ArgumentError, ':permissions must be a Hash' unless attributes[:permissions].is_a?(Hash)
19
+
20
+ attributes.each { |k,v| instance_variable_set("@#{k}", v) }
21
+ end
22
+
23
+
24
+ # Initialize a new ApiAccess from api data
25
+ # @param [Hash] data the hash of data provided by the API
26
+ def self.from_api(data)
27
+ attributes = {}
28
+ attributes[:id] = data['apiid'].to_i
29
+ attributes[:name] = data['name']
30
+ attributes[:permissions] = data['permissions'].is_a?(Hash) ? data['permissions'] : {}
19
31
 
20
32
  # Rubyfy permissions hash
21
- @permissions.keys.each do |key|
22
- @permissions[key] = @permissions[key].to_i
23
- @permissions[(key.to_sym rescue key) || key] = @permissions.delete(key) # Symbolize key
33
+ attributes[:permissions].keys.each do |key|
34
+ attributes[:permissions][key] = attributes[:permissions][key].to_i
35
+ attributes[:permissions][(key.to_sym rescue key) || key] = attributes[:permissions].delete(key) # Symbolize key
24
36
  end
37
+ attributes[:permissions].freeze
38
+
39
+ return new(attributes)
25
40
  end
26
41
 
27
42
  # Determine if this API has read access for the provided permission
@@ -44,6 +59,6 @@ module Osm
44
59
  return @id == Osm::Api.api_id.to_i
45
60
  end
46
61
 
47
- end
62
+ end # Class
48
63
 
49
- end
64
+ end # Module
@@ -10,44 +10,58 @@ module Osm
10
10
  # @!attribute [r] totals
11
11
  # @return [Hash] the total number of each badge which is due
12
12
 
13
- # Initialize a new Event using the hash returned by the API call
14
- # @param data the hash of data for the object returned by the API
15
- def initialize(data)
13
+ # Initialize a new DueBadges
14
+ # @param [Hash] attributes the hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
15
+ def initialize(attributes={})
16
+ [:descriptions, :by_member, :totals].each do |attribute|
17
+ raise ArgumentError, ":#{attribute} must be a Hash" unless attributes[attribute].is_a?(Hash)
18
+ end
19
+
20
+ attributes.each { |k,v| instance_variable_set("@#{k}", v) }
21
+ end
22
+
23
+
24
+ # Initialize a new DueBadges from api data
25
+ # @param [Hash] data the hash of data provided by the API
26
+ def self.from_api(data)
16
27
  data = {} unless data.is_a?(Hash)
28
+ attributes = {}
17
29
 
18
- @pending = data['pending'].is_a?(Hash) ? Osm::symbolize_hash(data['pending']) : {}
19
- @descriptions = data['description'].is_a?(Hash) ? Osm::symbolize_hash(data['description']) : {}
30
+ attributes[:pending] = data['pending'].is_a?(Hash) ? Osm::symbolize_hash(data['pending']) : {}
31
+ attributes[:descriptions] = data['description'].is_a?(Hash) ? Osm::symbolize_hash(data['description']) : {}
20
32
 
21
- @pending.each_key do |key|
22
- @pending[key].each_with_index do |item, index|
23
- @pending[key][index] = item = Osm::symbolize_hash(item)
33
+ attributes[:pending].each_key do |key|
34
+ attributes[:pending][key].each_with_index do |item, index|
35
+ attributes[:pending][key][index] = item = Osm::symbolize_hash(item)
24
36
  item[:sid] = item[:sid].to_i
25
37
  item[:completed] = item[:completed].to_i
26
38
  end
27
39
  end
28
- @descriptions.each_key do |key|
29
- @descriptions[key] = Osm::symbolize_hash(@descriptions[key])
30
- @descriptions[key][:section] = @descriptions[key][:section].to_sym
31
- @descriptions[key][:type] = @descriptions[key][:type].to_sym
40
+ attributes[:descriptions].each_key do |key|
41
+ attributes[:descriptions][key] = Osm::symbolize_hash(attributes[:descriptions][key])
42
+ attributes[:descriptions][key][:section] = attributes[:descriptions][key][:section].to_sym
43
+ attributes[:descriptions][key][:type] = attributes[:descriptions][key][:type].to_sym
32
44
  end
33
45
 
34
46
 
35
- @by_member = {}
36
- @totals = {}
37
- @pending.each_key do |key|
38
- @pending[key].each do |item|
47
+ attributes[:by_member] = {}
48
+ attributes[:totals] = {}
49
+ attributes[:pending].each_key do |key|
50
+ attributes[:pending][key].each do |item|
39
51
  name = "#{item[:firstname]} #{item[:lastname]}"
40
- by_member[name] = [] if by_member[name].nil?
52
+ attributes[:by_member][name] = [] if attributes[:by_member][name].nil?
41
53
 
42
54
  badge = {
43
55
  :badge => key,
44
56
  :extra_information => item[:extra]
45
57
  }
46
- by_member[name].push badge
47
- @totals[key] = {} if @totals[key].nil?
48
- @totals[key][item[:extra]] = @totals[key][item[:extra]].to_i + 1
58
+ attributes[:by_member][name].push badge
59
+ attributes[:totals][key] = {} if attributes[:totals][key].nil?
60
+ attributes[:totals][key][item[:extra]] = attributes[:totals][key][item[:extra]].to_i + 1
49
61
  end
50
62
  end
63
+
64
+ new(attributes)
51
65
  end
52
66
 
53
67
  # Check if there are no badges due
@@ -56,6 +70,6 @@ module Osm
56
70
  return @by_member.empty?
57
71
  end
58
72
 
59
- end
73
+ end # Class
60
74
 
61
- end
75
+ end # Module
data/lib/osm/evening.rb CHANGED
@@ -6,7 +6,7 @@ module Osm
6
6
  attr_reader :start_time, :end_time
7
7
  # @!attribute [rw] evening_id
8
8
  # @return [Fixnum] the id of the evening
9
- # @!attribute [rw] sectionid
9
+ # @!attribute [rw] section_id
10
10
  # @return [Fixnum] the section the evening belongs to
11
11
  # @!attribute [rw] title
12
12
  # @return [String] the title of the evening
@@ -23,35 +23,59 @@ module Osm
23
23
  # @!attribute [rw] meeting_date
24
24
  # @return [Date] the date of the evening
25
25
  # @!attribute [rw] activities
26
- # @return [Array<EveningActivity>] list of activities being done during the evening
26
+ # @return [Array<Activity>] list of activities being done during the evening
27
27
  # @!attribute [rw] start_time
28
28
  # @return [String] the start time (hh:mm)
29
29
  # @!attribute [rw] end_time
30
30
  # @return [String] the end time (hh:mm)
31
31
 
32
- # Initialize a new ProgrammeItem using the hash returned by the API call
33
- # @param data the hash of data for the object returned by the API
32
+ # Initialize a new Evening
33
+ # @param [Hash] attributes the hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
34
+ def initialize(attributes={})
35
+ [:evening_id, :section_id].each do |attribute|
36
+ raise ArgumentError, ":#{attribute} must be nil or a Fixnum > 0" unless attributes[attribute].nil? || (attributes[attribute].is_a?(Fixnum) && attributes[attribute] > 0)
37
+ end
38
+ [:title, :notes_for_parents, :games, :pre_notes, :post_notes, :leaders].each do |attribute|
39
+ raise ArgumentError, ":#{attribute} must be nil or a String" unless (attributes[attribute].nil? || attributes[attribute].is_a?(String))
40
+ end
41
+ raise ArgumentError, ':meeting_date must be a Date' unless attributes[:meeting_date].is_a?(Date)
42
+ raise ArgumentError, ':activities must be nil or an Array of Osm::Evening::Activity' unless (attributes[:activities].nil? || Osm::is_array_of?(attributes[:activities], Osm::Evening::Activity))
43
+
44
+ attributes.each { |k,v| send("#{k}=", v) }
45
+
46
+ @activities ||= []
47
+ @title ||= 'Unnamed meeting'
48
+ [:notes_for_parents, :games, :pre_notes, :post_notes, :leaders].each do |attribute|
49
+ instance_variable_set("@#{attribute}", '') if instance_variable_get("@#{attribute}").nil?
50
+ end
51
+ end
52
+
53
+
54
+ # Initialize a new Evening from api data
55
+ # @param [Hash] data the hash of data provided by the API
34
56
  # @param activities an array of hashes to generate the list of ProgrammeActivity objects
35
- def initialize(data, activities)
36
- @evening_id = Osm::to_i_or_nil(data['eveningid'])
37
- @section_id = Osm::to_i_or_nil(data['sectionid'])
38
- @title = data['title'] || 'Unnamed meeting'
39
- @notes_for_parents = data['notesforparents'] || ''
40
- @games = data['games'] || ''
41
- @pre_notes = data['prenotes'] || ''
42
- @post_notes = data['postnotes'] || ''
43
- @leaders = data['leaders'] || ''
44
- @start_time = data['starttime'].nil? ? nil : data['starttime'][0..4]
45
- @end_time = data['endtime'].nil? ? nil : data['endtime'][0..4]
46
- @meeting_date = Osm::parse_date(data['meetingdate'])
47
-
48
- @activities = Array.new
57
+ def self.from_api(data, activities)
58
+ attributes = {}
59
+ attributes[:evening_id] = Osm::to_i_or_nil(data['eveningid'])
60
+ attributes[:section_id] = Osm::to_i_or_nil(data['sectionid'])
61
+ attributes[:title] = data['title'] || 'Unnamed meeting'
62
+ attributes[:notes_for_parents] = data['notesforparents'] || ''
63
+ attributes[:games] = data['games'] || ''
64
+ attributes[:pre_notes] = data['prenotes'] || ''
65
+ attributes[:post_notes] = data['postnotes'] || ''
66
+ attributes[:leaders] = data['leaders'] || ''
67
+ attributes[:start_time] = data['starttime'].nil? ? nil : data['starttime'][0..4]
68
+ attributes[:end_time] = data['endtime'].nil? ? nil : data['endtime'][0..4]
69
+ attributes[:meeting_date] = Osm::parse_date(data['meetingdate'])
70
+
71
+ attributes[:activities] = Array.new
49
72
  unless activities.nil?
50
73
  activities.each do |item|
51
- @activities.push EveningActivity.new(item)
74
+ attributes[:activities].push Evening::Activity.from_api(item)
52
75
  end
53
76
  end
54
- @activities.freeze
77
+
78
+ new(attributes)
55
79
  end
56
80
 
57
81
  # Custom setters for times
@@ -67,11 +91,11 @@ module Osm
67
91
 
68
92
  # Get the evening's data for use with the API
69
93
  # @return [Hash]
70
- def data_for_saving
94
+ def to_api
71
95
  {
72
96
  'eveningid' => evening_id,
73
97
  'sectionid' => section_id,
74
- 'meetingdate' => meeting_date.try(:strftime, '%Y-%m-%d'),
98
+ 'meetingdate' => meeting_date.strftime('%Y-%m-%d'),
75
99
  'starttime' => start_time,
76
100
  'endtime' => end_time,
77
101
  'title' => title,
@@ -80,15 +104,15 @@ module Osm
80
104
  'postnotes' => post_notes,
81
105
  'games' => games,
82
106
  'leaders' => leaders,
83
- 'activity' => activities_for_saving,
107
+ 'activity' => activities_for_to_api,
84
108
  }
85
109
  end
86
110
 
87
111
 
88
112
  private
89
- # Get the JSON for the activitied to pass to the OSM API
113
+ # Get the JSON for the activities to pass to the OSM API
90
114
  # @return [String]
91
- def activities_for_saving
115
+ def activities_for_to_api
92
116
  to_save = Array.new
93
117
  @activities.each do |activity|
94
118
  this_activity = {
@@ -101,8 +125,8 @@ module Osm
101
125
  end
102
126
 
103
127
 
104
- class EveningActivity
105
-
128
+ class Activity
129
+
106
130
  attr_reader :activity_id, :title, :notes
107
131
  # @!attribute [r] activity_id
108
132
  # @return [Fixnum] the activity being done
@@ -111,14 +135,27 @@ module Osm
111
135
  # @!attribute [r] notes
112
136
  # @return [String] notes relevant to doing this activity on this evening
113
137
 
114
- # Initialize a new EveningActivity using the hash returned by the API call
115
- # @param data the hash of data for the object returned by the API
116
- def initialize(data)
117
- @activity_id = Osm::to_i_or_nil(data['activityid'])
118
- @title = data['title']
119
- @notes = data['notes']
120
- end
138
+ # Initialize a new Evening::Activity
139
+ # @param [Hash] attributes the hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
140
+ def initialize(attributes={})
141
+ raise ArgumentError, ':activity_id must be a Fixnum > 0' unless (attributes[:activity_id].is_a?(Fixnum) && attributes[:activity_id] > 0)
142
+ raise ArgumentError, ':title must be nil or a String' unless (attributes[:title].nil? || attributes[:title].is_a?(String))
143
+ raise ArgumentError, ':notes must be nil or a String' unless (attributes[:notes].nil? || attributes[:notes].is_a?(String))
121
144
 
145
+ attributes.each { |k,v| instance_variable_set("@#{k}", v) }
146
+ end
147
+
148
+
149
+ # Initialize a new Evening::Activity from api data
150
+ # @param [Hash] data the hash of data provided by the API
151
+ def self.from_api(data)
152
+ new({
153
+ :activity_id => Osm::to_i_or_nil(data['activityid']),
154
+ :title => data['title'],
155
+ :notes => data['notes'],
156
+ })
157
+ end
158
+
122
159
  end
123
160
 
124
161
 
data/lib/osm/event.rb CHANGED
@@ -20,17 +20,36 @@ module Osm
20
20
  # @!attribute [r] notes
21
21
  # @return [String] notes about the event
22
22
 
23
- # Initialize a new Event using the hash returned by the API call
24
- # @param data the hash of data for the object returned by the API
25
- def initialize(data)
26
- @id = Osm::to_i_or_nil(data['eventid'])
27
- @section_id = Osm::to_i_or_nil(data['sectionid'])
28
- @name = data['name']
29
- @start = Osm::make_datetime(data['startdate'], data['starttime'])
30
- @end = Osm::make_datetime(data['enddate'], data['endtime'])
31
- @cost = data['cost']
32
- @location = data['location']
33
- @notes = data['notes']
23
+ # Initialize a new Event
24
+ # @param [Hash] attributes the hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
25
+ def initialize(attributes={})
26
+ [:id, :section_id].each do |attribute|
27
+ raise ArgumentError, ":#{attribute} must be nil or a Fixnum > 0" unless attributes[attribute].nil? || (attributes[attribute].is_a?(Fixnum) && attributes[attribute] > 0)
28
+ end
29
+ raise ArgumentError, ':name must be a String' unless attributes[:name].is_a?(String)
30
+ raise ArgumentError, ':start must be nil or a DateTime' unless attributes[:start].nil? || attributes[:start].is_a?(DateTime)
31
+ raise ArgumentError, ':end must be nil or a DateTime' unless attributes[:end].nil? || attributes[:end].is_a?(DateTime)
32
+ [:cost, :location, :notes].each do |attribute|
33
+ raise ArgumentError, ":#{attribute} must be nil or a String" unless attributes[attribute].nil? || attributes[attribute].is_a?(String)
34
+ end
35
+
36
+ attributes.each { |k,v| instance_variable_set("@#{k}", v) }
37
+ end
38
+
39
+
40
+ # Initialize a new Event from api data
41
+ # @param [Hash] data the hash of data provided by the API
42
+ def self.from_api(data)
43
+ new({
44
+ :id => Osm::to_i_or_nil(data['eventid']),
45
+ :section_id => Osm::to_i_or_nil(data['sectionid']),
46
+ :name => data['name'],
47
+ :start => Osm::make_datetime(data['startdate'], data['starttime']),
48
+ :end => Osm::make_datetime(data['enddate'], data['endtime']),
49
+ :cost => data['cost'],
50
+ :location => data['location'],
51
+ :notes => data['notes'],
52
+ })
34
53
  end
35
54
 
36
55
  end
data/lib/osm/grouping.rb CHANGED
@@ -7,18 +7,32 @@ module Osm
7
7
  # @return [Fixnum] the id for grouping
8
8
  # @!attribute [r] name
9
9
  # @return [String] the name of the grouping
10
- # @!attribute [r] id
10
+ # @!attribute [r] active
11
11
  # @return [Boolean] wether the grouping is active
12
12
  # @!attribute [r] points
13
13
  # @return [Fixnum] the points awarded to the grouping
14
14
 
15
- # Initialize a new Grouping using the hash returned by the API call
16
- # @param data the hash of data for the object returned by the API
17
- def initialize(data)
18
- @id = Osm::to_i_or_nil(data['patrolid'])
19
- @name = data['name']
20
- @active = (data['active'] == 1)
21
- @points = Osm::to_i_or_nil(data['points'])
15
+ # Initialize a new Grouping
16
+ # @param [Hash] attributes the hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
17
+ def initialize(attributes={})
18
+ raise ArgumentError, ':id must be a Fixnum > 0' unless (attributes[:id].is_a?(Fixnum) && attributes[:id] > 0)
19
+ raise ArgumentError, ':name must be a String' unless attributes[:name].is_a?(String)
20
+ raise ArgumentError, ':active must be nil or a Boolean' unless attributes[:active].nil? || [true, false].include?(attributes[:active])
21
+ raise ArgumentError, ':points must be nil or a Fixnum >= 0' unless attributes[:points].nil? || (attributes[:points].is_a?(Fixnum) && attributes[:points] >= 0)
22
+
23
+ attributes.each { |k,v| instance_variable_set("@#{k}", v) }
24
+ end
25
+
26
+
27
+ # Initialize a new Grouping from api data
28
+ # @param [Hash] data the hash of data provided by the API
29
+ def self.from_api(data)
30
+ new({
31
+ :id => Osm::to_i_or_nil(data['patrolid']),
32
+ :name => data['name'],
33
+ :active => (data['active'] == 1),
34
+ :points => Osm::to_i_or_nil(data['points']),
35
+ })
22
36
  end
23
37
 
24
38
  end
data/lib/osm/member.rb CHANGED
@@ -2,7 +2,7 @@ module Osm
2
2
 
3
3
  class Member
4
4
 
5
- attr_reader :id, :section_id, :type, :first_name, :last_name, :email1, :email2, :email3, :email4, :phone1, :phone2, :phone3, :phone4, :address, :address2, :date_of_birth, :started, :joined_in_years, :parents, :notes, :medical, :religion, :school, :ethnicity, :subs, :grouping_id, :grouping_leader, :joined, :age, :joined_years
5
+ attr_reader :id, :section_id, :type, :first_name, :last_name, :email1, :email2, :email3, :email4, :phone1, :phone2, :phone3, :phone4, :address, :address2, :date_of_birth, :started, :joining_in_years, :parents, :notes, :medical, :religion, :school, :ethnicity, :subs, :grouping_id, :grouping_leader, :joined, :age, :joined_years
6
6
  # @!attribute [r] id
7
7
  # @return [Fixnum] the id for the member
8
8
  # @!attribute [r] section_id
@@ -37,7 +37,7 @@ module Osm
37
37
  # @return [Date] the member's date of birth
38
38
  # @!attribute [r] started
39
39
  # @return [Date] when the member started Scouting
40
- # @!attribute [r] joined_in_years
40
+ # @!attribute [r] joining_in_years
41
41
  # @return [Fixnum] ?
42
42
  # @!attribute [r] parents
43
43
  # @return [String] the member's parent's names
@@ -61,43 +61,66 @@ module Osm
61
61
  # @return [Date] when the member joined the section
62
62
  # @!attribute [r] age
63
63
  # @return [String] the member's current age (yy/mm)
64
- # @!attribute [r] joined_years
64
+ # @!attribute [r] joining_years
65
65
  # @return [Fixnum] how many years the member has been in Scouting
66
66
 
67
67
 
68
- # Initialize a new Member using the hash returned by the API call
69
- # @param data the hash of data for the object returned by the API
70
- def initialize(data)
71
- @id = Osm::to_i_or_nil(data['scoutid'])
72
- @section_id = Osm::to_i_or_nil(data['sectionidO'])
73
- @type = data['type']
74
- @first_name = data['firstname']
75
- @last_name = data['lastname']
76
- @email1 = data['email1']
77
- @email2 = data['email2']
78
- @email3 = data['email3']
79
- @email4 = data['email4']
80
- @phone1 = data['phone1']
81
- @phone2 = data['phone2']
82
- @phone3 = data['phone3']
83
- @phone4 = data['phone4']
84
- @address = data['address']
85
- @address2 = data['address2']
86
- @date_of_birth = Osm::parse_date(data['dob'])
87
- @started = Osm::parse_date(data['started'])
88
- @joined_in_years = data['joining_in_yrs'].to_i
89
- @parents = data['parents']
90
- @notes = data['notes']
91
- @medical = data['medical']
92
- @religion = data['religion']
93
- @school = data['school']
94
- @ethnicity = data['ethnicity']
95
- @subs = data['subs']
96
- @grouping_id = Osm::to_i_or_nil(data['patrolidO'])
97
- @grouping_leader = data['patrolleaderO'] # 0 - No, 1 = seconder, 2 = sixer
98
- @joined = Osm::parse_date(data['joined'])
99
- @age = data['age'] # 'yy / mm'
100
- @joined_years = data['yrs'].to_i
68
+ # Initialize a new Member
69
+ # @param [Hash] attributes the hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
70
+ def initialize(attributes={})
71
+ [:id, :section_id, :grouping_id].each do |attribute|
72
+ raise ArgumentError, ":#{attribute} must be nil or a Fixnum > 0" unless attributes[attribute].nil? || (attributes[attribute].is_a?(Fixnum) && attributes[attribute] > 0)
73
+ end
74
+ [:joined_years, :grouping_leader].each do |attribute|
75
+ raise ArgumentError, ":#{attribute} must be nil or a Fixnum >= 0" unless attributes[attribute].nil? || (attributes[attribute].is_a?(Fixnum) && attributes[attribute] >= 0)
76
+ end
77
+ raise ArgumentError, ':joining_in_years must be nil or a Fixnum' unless attributes[:joining_in_years].nil? || attributes[:joining_in_years].is_a?(Fixnum)
78
+ [:type, :first_name, :last_name, :email1, :email2, :email3, :email4, :phone1, :phone2, :phone3, :phone4, :address, :address2, :parents, :notes, :medical, :religion, :school, :ethnicity, :subs, :age].each do |attribute|
79
+ raise ArgumentError, ":#{attribute} must be nil or a String" unless attributes[attribute].nil? || attributes[attribute].is_a?(String)
80
+ end
81
+ [:date_of_birth, :started, :joined].each do |attribute|
82
+ raise ArgumentError, ":#{attribute} must be nil or a Date" unless attributes[attribute].nil? || attributes[attribute].is_a?(Date)
83
+ end
84
+
85
+ attributes.each { |k,v| instance_variable_set("@#{k}", v) }
86
+ end
87
+
88
+
89
+ # Initialize a new Member from api data
90
+ # @param [Hash] data the hash of data provided by the API
91
+ def self.from_api(data)
92
+ new({
93
+ :id => Osm::to_i_or_nil(data['scoutid']),
94
+ :section_id => Osm::to_i_or_nil(data['sectionidO']),
95
+ :type => data['type'],
96
+ :first_name => data['firstname'],
97
+ :last_name => data['lastname'],
98
+ :email1 => data['email1'],
99
+ :email2 => data['email2'],
100
+ :email3 => data['email3'],
101
+ :email4 => data['email4'],
102
+ :phone1 => data['phone1'],
103
+ :phone2 => data['phone2'],
104
+ :phone3 => data['phone3'],
105
+ :phone4 => data['phone4'],
106
+ :address => data['address'],
107
+ :address2 => data['address2'],
108
+ :date_of_birth => Osm::parse_date(data['dob']),
109
+ :started => Osm::parse_date(data['started']),
110
+ :joining_in_years => data['joining_in_yrs'].to_i,
111
+ :parents => data['parents'],
112
+ :notes => data['notes'],
113
+ :medical => data['medical'],
114
+ :religion => data['religion'],
115
+ :school => data['school'],
116
+ :ethnicity => data['ethnicity'],
117
+ :subs => data['subs'],
118
+ :grouping_id => Osm::to_i_or_nil(data['patrolidO']),
119
+ :grouping_leader => data['patrolleaderO'],
120
+ :joined => Osm::parse_date(data['joined']),
121
+ :age => data['age'],
122
+ :joined_years => data['yrs'].to_i,
123
+ })
101
124
  end
102
125
 
103
126
  # Get the years element of this scout's age