67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
# File 'lib/gs_graph/page/category_attributes.rb', line 67
def initialize_with_category_specific_attributes(identifier, attributes = {})
initialize_without_category_specific_attributes identifier, attributes
@@category_attributes[:raw].each do |key|
self.send :"#{key}=", attributes[key]
end
@@category_attributes[:symbols].each do |key|
self.send :"#{key}=", []
if attributes[key]
self.send :"#{key}=", attributes[key].keys.collect(&:to_sym)
end
end
@@category_attributes[:date].each do |key|
date = if attributes[key]
begin
Date.parse attributes[key]
rescue
attributes[key]
end
end
self.send :"#{key}=", date
end
@checkin_count = attributes[:checkins]
@hours = {}
if attributes[:hours]
attributes[:hours].each do |key, value|
date, index, mode = key.split('_')
index = index.to_i - 1
date, mode = date.to_sym, mode.to_sym
if value.class == Fixnum
time = Time.at(value).in_time_zone("Pacific Time (US & Canada)")
else
time = Time.parse(value)
end
time = Time.utc(1970, 1, 1, time.hour, time.min)
@hours[date] ||= []
@hours[date][index] ||= {}
@hours[date][index][mode] = time
end
end
if attributes[:location]
@location = Venue.new(attributes[:location])
end
end
|