Exception: Tempo::TimeConflictError
- Inherits:
-
ArgumentError
- Object
- ArgumentError
- Tempo::TimeConflictError
- Defined in:
- lib/tempo/exceptions.rb
Overview
This error is raised when an existing time period conflicts with a time or time period All parameters are optional, and will be build into the error string if supplied
Expected parameters are Time objects, but nil or strings will be handled as well
examples:
() => “time conflicts with existing record” (<8:00>, <10:00>) => “time conflicts with existing record: 8:00 - 10:00” (<8:00>, <10:00>, <9:00>) => “time <9:00> conflicts with existing record: 8:00 - 10:00” (<8:00>, <10:00>, <9:00>, <9:30>) => “time <9:00 - 9:30> conflicts with existing record: 8:00 - 10:00” (<8:00>, :running) => “time conflicts with existing record: 8:00 - running”
Instance Method Summary collapse
-
#initialize(start_time = nil, end_time = nil, target_start_time = nil, target_end_time = nil) ⇒ TimeConflictError
constructor
A new instance of TimeConflictError.
- #to_s ⇒ Object
Constructor Details
#initialize(start_time = nil, end_time = nil, target_start_time = nil, target_end_time = nil) ⇒ TimeConflictError
Returns a new instance of TimeConflictError.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tempo/exceptions.rb', line 22 def initialize(start_time=nil, end_time=nil, target_start_time=nil, target_end_time=nil) @end_time = (end_time.kind_of? Time) ? end_time.strftime('%H:%M') : end_time.to_s @end_time = " - #{@end_time}" if !@end_time.empty? @existing = (start_time.kind_of? Time) ? ": #{start_time.strftime('%H:%M')}#{@end_time}" : start_time.to_s @target_end_time = (target_end_time.kind_of? Time) ? "#{target_end_time.strftime('%H:%M')}" : target_end_time.to_s @target_end_time = " - #{@target_end_time}" if !@target_end_time.empty? @target = (target_start_time.kind_of? Time) ? "<#{target_start_time.strftime('%H:%M')}#{@target_end_time}> " : "" = "time #{@target}conflicts with existing record#{@existing}" end |
Instance Method Details
#to_s ⇒ Object
35 36 37 |
# File 'lib/tempo/exceptions.rb', line 35 def to_s end |