Class: MypageTools::Shift
- Inherits:
-
Object
- Object
- MypageTools::Shift
- Includes:
- Icalendar
- Defined in:
- lib/mypage_tools/shift.rb
Overview
Data structure to represent a single shift on a single day
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#day_of_week ⇒ Object
Returns the value of attribute day_of_week.
-
#start ⇒ Object
Returns the value of attribute start.
-
#stop ⇒ Object
Returns the value of attribute stop.
Instance Method Summary collapse
-
#initialize(day_of_week = nil, date = nil, start = nil, stop = nil) ⇒ Shift
constructor
A new instance of Shift.
- #not_scheduled? ⇒ Boolean
- #to_ical_event ⇒ Object
Constructor Details
#initialize(day_of_week = nil, date = nil, start = nil, stop = nil) ⇒ Shift
Returns a new instance of Shift.
7 8 9 10 11 12 |
# File 'lib/mypage_tools/shift.rb', line 7 def initialize day_of_week=nil, date=nil, start=nil, stop=nil @day_of_week = day_of_week @date = date @start = start @stop = stop end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
5 6 7 |
# File 'lib/mypage_tools/shift.rb', line 5 def date @date end |
#day_of_week ⇒ Object
Returns the value of attribute day_of_week.
5 6 7 |
# File 'lib/mypage_tools/shift.rb', line 5 def day_of_week @day_of_week end |
#start ⇒ Object
Returns the value of attribute start.
5 6 7 |
# File 'lib/mypage_tools/shift.rb', line 5 def start @start end |
#stop ⇒ Object
Returns the value of attribute stop.
5 6 7 |
# File 'lib/mypage_tools/shift.rb', line 5 def stop @stop end |
Instance Method Details
#not_scheduled? ⇒ Boolean
26 27 28 |
# File 'lib/mypage_tools/shift.rb', line 26 def not_scheduled? @start == "00:00AM" && @stop == "00:00AM" end |
#to_ical_event ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/mypage_tools/shift.rb', line 30 def to_ical_event event = Event.new event.start = DateTime.parse(self.date + " " + self.start + " PST") event.end = DateTime.parse(self.date + " " + self.stop + " PST") event.description = "Work at Apple" event.summary = "Work (Apple)" event.location = "Apple Store University Village, 2656 Northeast University Village Street, Seattle, WA, US" event end |