Class: OFlow::Stamp

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

Overview

Information used to identify a location and time that a Box was received. Stamps are placed in Trackers.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(location, op = nil, time = nil) ⇒ Stamp

Create a new Stamp.

Parameters:

  • location (String)

    full name of Task that created the Stamp in a Tracker

  • op (Symbol) (defaults to: nil)

    operation that caused the Stamp to be created

  • time (Time) (defaults to: nil)

    time the Stamp was created



21
22
23
24
25
# File 'lib/oflow/stamp.rb', line 21

def initialize(location, op=nil, time=nil)
  @location = location
  @op = op
  @time = (time || Time.now).utc
end

Instance Attribute Details

#locationObject (readonly)

Full name of Task that created the Stamp in a Tracker.



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

def location
  @location
end

#opObject (readonly)

Operation that caused the Stamp to be created.



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

def op
  @op
end

#timeObject (readonly)

The time the Stamp was created.



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

def time
  @time
end

Instance Method Details

#to_sObject Also known as: inspect

Returns a String representation of the Stamp.



33
34
35
# File 'lib/oflow/stamp.rb', line 33

def to_s()
  "#{@location}-#{@op}@#{@time.iso8601(9)}"
end

#whereObject

Returns a string composed of the location and operation.



28
29
30
# File 'lib/oflow/stamp.rb', line 28

def where()
  "#{@location}-#{@op}"
end