Class: Scheduler::Meeting
- Inherits:
-
Object
- Object
- Scheduler::Meeting
- Includes:
- ScheduleHelper
- Defined in:
- lib/ruby/scheduler/meeting.rb
Constant Summary collapse
- VALID_TYPES =
[:offsite, :onsite]
Instance Attribute Summary collapse
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Meeting
constructor
Initialize Meeting object.
-
#next_start_time ⇒ Object
Additonal class methods Calculate next meeting start_time Output: - Time.
-
#offsite? ⇒ Boolean
Conditional methods Conditional method to check if type is offsite Output: - boolean.
-
#offsite_buffer ⇒ Object
Calcuate offsite buffer for travel (30 minutes) Output: - Integer.
-
#set_end_time ⇒ Object
Setter method for end_time attribute Input: - NONE.
-
#set_start_time(start_time) ⇒ Object
Setter methods Setter method for start_time attribute Input: - Time.
Constructor Details
#initialize(params = {}) ⇒ Meeting
Initialize Meeting object
16 17 18 19 20 21 22 23 24 |
# File 'lib/ruby/scheduler/meeting.rb', line 16 def initialize(params = {}) @name = params.fetch(:name, nil) @duration = params.fetch(:duration, 0) @type = params.fetch(:type, nil) @start_time = params.fetch(:start_time, nil) @end_time = params.fetch(:end_time, nil) validate! end |
Instance Attribute Details
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
10 11 12 |
# File 'lib/ruby/scheduler/meeting.rb', line 10 def duration @duration end |
#end_time ⇒ Object
Returns the value of attribute end_time.
11 12 13 |
# File 'lib/ruby/scheduler/meeting.rb', line 11 def end_time @end_time end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/ruby/scheduler/meeting.rb', line 10 def name @name end |
#start_time ⇒ Object
Returns the value of attribute start_time.
11 12 13 |
# File 'lib/ruby/scheduler/meeting.rb', line 11 def start_time @start_time end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/ruby/scheduler/meeting.rb', line 10 def type @type end |
Instance Method Details
#next_start_time ⇒ Object
Additonal class methods Calculate next meeting start_time Output:
-
Time
54 55 56 |
# File 'lib/ruby/scheduler/meeting.rb', line 54 def next_start_time end_time + to_seconds(offsite_buffer) end |
#offsite? ⇒ Boolean
Conditional methods Conditional method to check if type is offsite Output:
-
boolean
46 47 48 |
# File 'lib/ruby/scheduler/meeting.rb', line 46 def offsite? type == :offsite end |
#offsite_buffer ⇒ Object
Calcuate offsite buffer for travel (30 minutes) Output:
-
Integer
61 62 63 |
# File 'lib/ruby/scheduler/meeting.rb', line 61 def offsite_buffer offsite? ? 0.5 : 0.0 end |
#set_end_time ⇒ Object
Setter method for end_time attribute Input:
-
NONE
37 38 39 40 |
# File 'lib/ruby/scheduler/meeting.rb', line 37 def set_end_time return unless start_time @end_time = start_time + to_seconds(duration) end |
#set_start_time(start_time) ⇒ Object
Setter methods Setter method for start_time attribute Input:
-
Time
30 31 32 |
# File 'lib/ruby/scheduler/meeting.rb', line 30 def set_start_time(start_time) @start_time = start_time end |