Class: MypageTools::Shift

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#dateObject

Returns the value of attribute date.



5
6
7
# File 'lib/mypage_tools/shift.rb', line 5

def date
  @date
end

#day_of_weekObject

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

#startObject

Returns the value of attribute start.



5
6
7
# File 'lib/mypage_tools/shift.rb', line 5

def start
  @start
end

#stopObject

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

Returns:

  • (Boolean)


26
27
28
# File 'lib/mypage_tools/shift.rb', line 26

def not_scheduled?
	@start == "00:00AM" && @stop == "00:00AM"
end

#to_ical_eventObject



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