Module: TemporalObject

Defined in:
lib/temporal_object.rb,
lib/temporal_object/version.rb

Overview

Author:

  • Craig A. Cook

Constant Summary collapse

VERSION =
"0.1.6"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#temporal_statusesObject

Array

of TimeSpan::TimeLine statuses for temporal attributes



9
10
11
# File 'lib/temporal_object.rb', line 9

def temporal_statuses
  @temporal_statuses
end

Instance Method Details

#add_timeline(timeline) ⇒ Array

add a timeline to the TemporalObject

Parameters:

  • timeline (TimeSpan::TimeLine)

    added to the object

Returns:

  • (Array)

    adjusted list of timelines if no exception raised.

Raises:

  • (ArgumentError)


19
20
21
22
# File 'lib/temporal_object.rb', line 19

def add_timeline(timeline)
  raise ArgumentError, "Can only add a TimeSpan::TimeLine to a TemporalObject's statuses" unless timeline.kind_of? TimeSpan::TimeLine
  @temporal_statuses << timeline
end

#initializeObject



11
12
13
14
# File 'lib/temporal_object.rb', line 11

def initialize
  super
  @temporal_statuses = []         # Array of TimeSpan::TimeLine
end

#remove_timeline(timeline) ⇒ TimeSpan::TimeLine?

delete the cited timeline

Parameters:

  • timeline (TimeSpan::TimeLine)

    timeline to delete

Returns:

  • (TimeSpan::TimeLine, nil)

    TimeLIne deleted if successful or nil if not

Raises:

  • ArgumentError if called with a non-TimeLine object



34
35
36
37
# File 'lib/temporal_object.rb', line 34

def remove_timeline(timeline)
  raise ArgumentError, "Can only remove a TimeLine with this call."  unless timeline.kind_of? TimeSpan::TimeLine
  @temporal_statuses.delete(timeline)
end

#remove_timelinesArray

remove all TimeLine s from the TemporalObject

Returns:

  • (Array)

    the associated timelines



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

def remove_timelines
  @temporal_statuses = []
end