Class: Qismo::Objects::OfficeHour
Overview
Defined Under Namespace
Classes: OfficeHourElement
Constant Summary
Constants included
from Types
Types::Bool, Types::Hash, Types::Int, Types::String
Instance Attribute Summary collapse
Instance Method Summary
collapse
from_array
Instance Attribute Details
44
|
# File 'lib/qismo/objects/office_hour.rb', line 44
attribute? :office_hours, Types.Array(OfficeHourElement.optional).optional
|
#offline_message ⇒ String
28
|
# File 'lib/qismo/objects/office_hour.rb', line 28
attribute? :offline_message, Types::String.optional
|
#online_message ⇒ String
24
|
# File 'lib/qismo/objects/office_hour.rb', line 24
attribute? :online_message, Types::String.optional
|
#send_offline_each_message ⇒ TrueClass, FalseClass
40
|
# File 'lib/qismo/objects/office_hour.rb', line 40
attribute? :send_offline_each_message, Types::Bool.optional
|
#send_online_if_resolved ⇒ TrueClass, FalseClass
36
|
# File 'lib/qismo/objects/office_hour.rb', line 36
attribute? :send_online_if_resolved, Types::Bool.optional
|
32
|
# File 'lib/qismo/objects/office_hour.rb', line 32
attribute? :timezone, Types::String.optional
|
Instance Method Details
#in_office_hour? ⇒ Boolean
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/qismo/objects/office_hour.rb', line 46
def in_office_hour?
return false if timezone.blank?
offset = ::Time.zone_offset(timezone)
tz_current = ::Time.current.getlocal(offset)
today_office_hour = office_hours.find { |oh| oh.day == tz_current.strftime("%u").to_i }
return false if today_office_hour.nil?
start_hour = today_office_hour.starttime
end_hour = today_office_hour.endtime
start_time = ::Time.parse("#{tz_current.year}-#{tz_current.month}-#{tz_current.day} #{start_hour} #{timezone}")
end_time = ::Time.parse("#{tz_current.year}-#{tz_current.month}-#{tz_current.day} #{end_hour} #{timezone}")
tz_current.between?(start_time, end_time)
end
|