Class: Osm::Evening

Inherits:
Object
  • Object
show all
Defined in:
lib/osm/evening.rb

Defined Under Namespace

Classes: EveningActivity

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, activities) ⇒ Evening

Initialize a new ProgrammeItem using the hash returned by the API call

Parameters:

  • data

    the hash of data for the object returned by the API

  • activities

    an array of hashes to generate the list of ProgrammeActivity objects



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

#activitiesArray<EveningActivity>

Returns list of activities being done during the evening.

Returns:

  • (Array<EveningActivity>)

    list of activities being done during the evening



7
8
9
# File 'lib/osm/evening.rb', line 7

def activities
  @activities
end

#end_timeString

Returns the end time (hh:mm).

Returns:

  • (String)

    the end time (hh:mm)



7
8
9
# File 'lib/osm/evening.rb', line 7

def end_time
  @end_time
end

#evening_idFixnum

Returns the id of the evening.

Returns:

  • (Fixnum)

    the id of the evening



7
8
9
# File 'lib/osm/evening.rb', line 7

def evening_id
  @evening_id
end

#gamesString

Returns games to be played during the evening.

Returns:

  • (String)

    games to be played during the evening



7
8
9
# File 'lib/osm/evening.rb', line 7

def games
  @games
end

#leadersString

Returns the leaders present at the evening.

Returns:

  • (String)

    the leaders present at the evening



7
8
9
# File 'lib/osm/evening.rb', line 7

def leaders
  @leaders
end

#meeting_dateDate

Returns the date of the evening.

Returns:

  • (Date)

    the date of the evening



7
8
9
# File 'lib/osm/evening.rb', line 7

def meeting_date
  @meeting_date
end

#notes_for_parentsString

Returns notes to be shared with parents.

Returns:

  • (String)

    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_notesString

Returns notes for the end of the evening.

Returns:

  • (String)

    notes for the end of the evening



7
8
9
# File 'lib/osm/evening.rb', line 7

def post_notes
  @post_notes
end

#pre_notesString

Returns notes for the start of the evening.

Returns:

  • (String)

    notes for the start of the evening



7
8
9
# File 'lib/osm/evening.rb', line 7

def pre_notes
  @pre_notes
end

#section_idObject

Returns the value of attribute section_id.



5
6
7
# File 'lib/osm/evening.rb', line 5

def section_id
  @section_id
end

#sectionidFixnum

Returns the section the evening belongs to.

Returns:

  • (Fixnum)

    the section the evening belongs to



# File 'lib/osm/evening.rb', line 7

#start_timeString

Returns the start time (hh:mm).

Returns:

  • (String)

    the start time (hh:mm)



7
8
9
# File 'lib/osm/evening.rb', line 7

def start_time
  @start_time
end

#titleString

Returns the title of the evening.

Returns:

  • (String)

    the title of the evening



7
8
9
# File 'lib/osm/evening.rb', line 7

def title
  @title
end

Instance Method Details

#data_for_savingHash

Get the evening’s data for use with the API

Returns:

  • (Hash)


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