class TimeSpan::RelativeTime

class RelativeTime #

#

public methods: #

comparators: < <= == != >= >                                                                      #
   work on any two RelativeTime objects on the same TimeLine                                      #
positioned?                                                                                       #
   true if a RelativeTime has been put on a TimeLine                                              #                                                                                   #
colinear_with?(RelativeTime.new)                                                                  #
   true if both RelativeTime objects are positioned and on same TimeLine                          #
                                                                                                  #

protected method: #

valid_and_comparable_with?(RelativeTime)                                                          #
   true if                                                                                        #
                                                                                                  #

diff cannot be done, it makes no sense, due to the fuzziness #

                                                                                                   #
RelativeTime must be within a TimeLine                                                             #

@author Craig A. Cook

Attributes

reference_to[RW]
time_line[RW]

Public Class Methods

new(tline, ref) click to toggle source

create a realtive time *within a time_line* after position @param tline [TimeSpan::TimeLine] TimeLIne on which this RelativeTime is placed @param ref [Object] the object placed on the timeline @return the .to_s of the referenced object

# File lib/time_span.rb, line 421
def initialize  tline, ref
   @time_line= tline
   @reference_to= ref
end

Public Instance Methods

clone() click to toggle source

@raise [NotImplementedError] cannot do without much more work

# File lib/time_span.rb, line 427
def clone
  raise NotImplementedError, "Cannot use base Ruby clone which can create illegal objects by gem rules."
end
colinear_with?(other_relative_time) click to toggle source

@param [TimeSpan::RelativeTime] other time to be sure is on self's TimeLIne @return [Boolean] true if both are on the same TimeLine

# File lib/time_span.rb, line 456
def colinear_with?(other_relative_time)
  other_relative_time.kind_of?(self.class) &&  other_relative_time.positioned? && positioned? &&  time_line.equal?(other_relative_time.time_line)
end
positioned?() click to toggle source

@return [Boolean] true if self has been properly placed on a TimeLine

# File lib/time_span.rb, line 450
def positioned?
  self.time_line && self.time_line.indices_of.include?(self)
end
to_s() click to toggle source

@return [String] the string representation of referenced object

# File lib/time_span.rb, line 434
def to_s
  @reference_to.to_s
end

Protected Instance Methods

valid_and_comparable_with?(other_relative_time) click to toggle source

@param [TimeSpan::RelativeTime] RelativeTime to check for comparability with @return [Boolean] true if they can be compared

# File lib/time_span.rb, line 465
def valid_and_comparable_with?(other_relative_time)
  !self.time_line.nil? && !other_relative_time.time_line.nil?  &&  colinear_with?(other_relative_time)
end