Class: ActiveInTime::Site

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(active_in_time, json) ⇒ Site

Returns a new instance of Site.



5
6
7
# File 'lib/ait_connect/site.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/site.rb', line 3

def json
  @json
end

Instance Method Details

#address_line_1Object



46
47
48
# File 'lib/ait_connect/site.rb', line 46

def address_line_1
  self.contact['address_line_1']
end

#address_line_2Object



50
51
52
# File 'lib/ait_connect/site.rb', line 50

def address_line_2
  self.contact['address_line_2']
end

#boroughObject



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

def borough
  self.contact['borough']
end

#contactObject

Contact info



30
31
32
# File 'lib/ait_connect/site.rb', line 30

def contact
  @json["contact"]
end

#countryObject



38
39
40
# File 'lib/ait_connect/site.rb', line 38

def country
  self.contact['country']
end

#emailObject



70
71
72
# File 'lib/ait_connect/site.rb', line 70

def email
  self.contact['email']
end

#facilitiesObject



88
89
90
91
92
93
94
95
96
97
# File 'lib/ait_connect/site.rb', line 88

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/site.rb', line 9

def fetch
  @json = @active_in_time.get("sites/#{id}")
  self
end

#idObject



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

def id
  @json["id"]
end

#latitudeObject



58
59
60
# File 'lib/ait_connect/site.rb', line 58

def latitude
  self.contact['latitude']
end

#longitudeObject



62
63
64
# File 'lib/ait_connect/site.rb', line 62

def longitude
  self.contact['longitude']
end

#managementObject



99
100
101
102
# File 'lib/ait_connect/site.rb', line 99

def management
  return {} if @json["management"].blank?
  return ActiveInTime::Management.new(@active_in_time,@json["management"])
end

#nameObject



22
23
24
# File 'lib/ait_connect/site.rb', line 22

def name
  @json["name"]
end

#post_codeObject



54
55
56
# File 'lib/ait_connect/site.rb', line 54

def post_code
  self.contact['post_code']
end

#post_townObject



34
35
36
# File 'lib/ait_connect/site.rb', line 34

def post_town
  self.contact['post_town']
end

#telephoneObject



66
67
68
# File 'lib/ait_connect/site.rb', line 66

def telephone
  self.contact['telephone']
end

#timetablesObject



78
79
80
81
82
83
84
85
86
# File 'lib/ait_connect/site.rb', line 78

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

#tldc_approvedObject



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

def tldc_approved
  @json['tldc_approved']
end

#websiteObject



74
75
76
# File 'lib/ait_connect/site.rb', line 74

def website
  self.contact['website']
end