Class: ActiveInTime::Timetable

Inherits:
Object
  • Object
show all
Defined in:
lib/ait_connect/timetable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(active_in_time, json) ⇒ Timetable

Returns a new instance of Timetable.



5
6
7
# File 'lib/ait_connect/timetable.rb', line 5

def initialize(active_in_time, json)
  @active_in_time, @json = active_in_time, json
end

Instance Attribute Details

#jsonObject (readonly)

Returns the value of attribute json.



3
4
5
# File 'lib/ait_connect/timetable.rb', line 3

def json
  @json
end

Instance Method Details

#facilitiesObject



22
23
24
25
26
27
28
29
30
# File 'lib/ait_connect/timetable.rb', line 22

def facilities
  return [] if !@json["facilities"] || @json["facilities"].empty?
  
  facilities = []
  json['facilities'].each do |facility|
    facilities << ActiveInTime::Facility.new(@active_in_time, facility)
  end
  facilities
end

#fetchObject



9
10
11
12
# File 'lib/ait_connect/timetable.rb', line 9

def fetch
  @json = @active_in_time.get("timetables/#{id}")["timetable"]
  self
end

#idObject



14
15
16
# File 'lib/ait_connect/timetable.rb', line 14

def id
  @json["id"]
end

#nameObject



18
19
20
# File 'lib/ait_connect/timetable.rb', line 18

def name
  @json["name"]
end

#timetable_entries(options = {}) ⇒ Object



42
43
44
# File 'lib/ait_connect/timetable.rb', line 42

def timetable_entries(options = {})
  @active_in_time.timetable_entries.find(self.id,options)
end

#timetable_sessionsObject



32
33
34
35
36
37
38
39
40
# File 'lib/ait_connect/timetable.rb', line 32

def timetable_sessions
  return [] if !@json["timetable_sessions"] || @json["timetable_sessions"].empty?
  
  timetable_sessions = []
  json['timetable_sessions'].each do |facility|
    timetable_sessions << ActiveInTime::TimetableSession.new(@active_in_time, facility)
  end
  timetable_sessions
end