Class: Osm::Evening
- Inherits:
-
Object
- Object
- Osm::Evening
- Defined in:
- lib/osm/evening.rb
Defined Under Namespace
Classes: EveningActivity
Instance Attribute Summary collapse
-
#activities ⇒ Array<EveningActivity>
List of activities being done during the evening.
-
#end_time ⇒ String
The end time (hh:mm).
-
#evening_id ⇒ Fixnum
The id of the evening.
-
#games ⇒ String
Games to be played during the evening.
-
#leaders ⇒ String
The leaders present at the evening.
-
#meeting_date ⇒ Date
The date of the evening.
-
#notes_for_parents ⇒ String
Notes to be shared with parents.
-
#post_notes ⇒ String
Notes for the end of the evening.
-
#pre_notes ⇒ String
Notes for the start of the evening.
-
#section_id ⇒ Object
Returns the value of attribute section_id.
-
#sectionid ⇒ Fixnum
The section the evening belongs to.
-
#start_time ⇒ String
The start time (hh:mm).
-
#title ⇒ String
The title of the evening.
Instance Method Summary collapse
-
#data_for_saving ⇒ Hash
Get the evening’s data for use with the API.
-
#initialize(data, activities) ⇒ Evening
constructor
Initialize a new ProgrammeItem using the hash returned by the API call.
Constructor Details
#initialize(data, activities) ⇒ Evening
Initialize a new ProgrammeItem using the hash returned by the API call
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/osm/evening.rb', line 35 def initialize(data, activities) @evening_id = Osm::to_i_or_nil(data['eveningid']) @section_id = Osm::to_i_or_nil(data['sectionid']) @title = data['title'] || 'Unnamed meeting' @notes_for_parents = data['notesforparents'] || '' @games = data['games'] || '' @pre_notes = data['prenotes'] || '' @post_notes = data['postnotes'] || '' @leaders = data['leaders'] || '' @start_time = data['starttime'].nil? ? nil : data['starttime'][0..4] @end_time = data['endtime'].nil? ? nil : data['endtime'][0..4] @meeting_date = Osm::parse_date(data['meetingdate']) @activities = Array.new unless activities.nil? activities.each do |item| @activities.push EveningActivity.new(item) end end @activities.freeze end |
Instance Attribute Details
#activities ⇒ Array<EveningActivity>
Returns list of activities being done during the evening.
7 8 9 |
# File 'lib/osm/evening.rb', line 7 def activities @activities end |
#end_time ⇒ String
Returns the end time (hh:mm).
7 8 9 |
# File 'lib/osm/evening.rb', line 7 def end_time @end_time end |
#evening_id ⇒ Fixnum
Returns the id of the evening.
7 8 9 |
# File 'lib/osm/evening.rb', line 7 def evening_id @evening_id end |
#games ⇒ String
Returns games to be played during the evening.
7 8 9 |
# File 'lib/osm/evening.rb', line 7 def games @games end |
#leaders ⇒ String
Returns the leaders present at the evening.
7 8 9 |
# File 'lib/osm/evening.rb', line 7 def leaders @leaders end |
#meeting_date ⇒ Date
Returns the date of the evening.
7 8 9 |
# File 'lib/osm/evening.rb', line 7 def meeting_date @meeting_date end |
#notes_for_parents ⇒ String
Returns notes to be shared with parents.
7 8 9 |
# File 'lib/osm/evening.rb', line 7 def notes_for_parents @notes_for_parents end |
#post_notes ⇒ String
Returns notes for the end of the evening.
7 8 9 |
# File 'lib/osm/evening.rb', line 7 def post_notes @post_notes end |
#pre_notes ⇒ String
Returns notes for the start of the evening.
7 8 9 |
# File 'lib/osm/evening.rb', line 7 def pre_notes @pre_notes end |
#section_id ⇒ Object
Returns the value of attribute section_id.
5 6 7 |
# File 'lib/osm/evening.rb', line 5 def section_id @section_id end |
#sectionid ⇒ Fixnum
Returns the section the evening belongs to.
|
# File 'lib/osm/evening.rb', line 7
|
#start_time ⇒ String
Returns the start time (hh:mm).
7 8 9 |
# File 'lib/osm/evening.rb', line 7 def start_time @start_time end |
#title ⇒ String
Returns the title of the evening.
7 8 9 |
# File 'lib/osm/evening.rb', line 7 def title @title end |
Instance Method Details
#data_for_saving ⇒ Hash
Get the evening’s data for use with the API
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/osm/evening.rb', line 70 def data_for_saving { 'eveningid' => evening_id, 'sectionid' => section_id, 'meetingdate' => meeting_date.try(:strftime, '%Y-%m-%d'), 'starttime' => start_time, 'endtime' => end_time, 'title' => title, 'notesforparents' => notes_for_parents, 'prenotes' => pre_notes, 'postnotes' => post_notes, 'games' => games, 'leaders' => leaders, 'activity' => activities_for_saving, } end |