Class: TemporalObject::TemporalObject

Inherits:
Object
  • Object
show all
Defined in:
lib/temporal_object.rb

Overview

Author:

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (TemporalObject) initialize(nom = "", reference_obj = Object.new)

A new instance of TemporalObject

Parameters:

  • nom (String) (defaults to: "")

    is the TemporalObject's name

  • reference_obj (Object) (defaults to: Object.new)

    is the object associated with this TemporalObject



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

def initialize(nom="", reference_obj=Object.new)
  @statuses = []         # Array of TimeSpan::TimeLine
  @name     = ""
  @reference_object = reference_obj
end

Instance Attribute Details

- (Object) name

String

object human readable identifier



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

def name
  @name
end

- (Object) reference_object

Object

associated Ruby Object of any kind



15
16
17
# File 'lib/temporal_object.rb', line 15

def reference_object
  @reference_object
end

- (Object) statuses

Array

of TimeSpan::TimeLine statuses for temporal attributes



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

def statuses
  @statuses
end

Instance Method Details

- (Array) add_timeline(timeline)

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)


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

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

- (TimeSpan::TimeLine?) remove_timeline(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



50
51
52
53
# File 'lib/temporal_object.rb', line 50

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

- (Array) remove_timelines

remove all TimeLine s from the TemporalObject

Returns:

  • (Array)

    the associated timelines



42
43
44
# File 'lib/temporal_object.rb', line 42

def remove_timelines
  @statuses = []
end