Class: Mnemosyne::Span
- Inherits:
-
Object
- Object
- Mnemosyne::Span
- Defined in:
- lib/mnemosyne/span.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#finish ⇒ Object
readonly
Returns the value of attribute finish.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
Instance Method Summary collapse
- #finish!(oneshot: false) ⇒ Object
-
#initialize(name, start: false, finish: false, meta: {}) ⇒ Span
constructor
A new instance of Span.
- #serialize ⇒ Object
- #start! ⇒ Object
Constructor Details
#initialize(name, start: false, finish: false, meta: {}) ⇒ Span
Returns a new instance of Span.
7 8 9 10 11 12 13 14 15 |
# File 'lib/mnemosyne/span.rb', line 7 def initialize(name, start: false, finish: false, meta: {}) @type = nil @name = name @meta = @uuid = ::SecureRandom.uuid @start = start @finish = finish end |
Instance Attribute Details
#finish ⇒ Object (readonly)
Returns the value of attribute finish.
5 6 7 |
# File 'lib/mnemosyne/span.rb', line 5 def finish @finish end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
5 6 7 |
# File 'lib/mnemosyne/span.rb', line 5 def @meta end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/mnemosyne/span.rb', line 5 def name @name end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
5 6 7 |
# File 'lib/mnemosyne/span.rb', line 5 def start @start end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/mnemosyne/span.rb', line 5 def type @type end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
5 6 7 |
# File 'lib/mnemosyne/span.rb', line 5 def uuid @uuid end |
Instance Method Details
#finish!(oneshot: false) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mnemosyne/span.rb', line 25 def finish!(oneshot: false) raise 'Already finished' if @finish @finish = ::Mnemosyne::Clock.tick if oneshot @start ||= @finish @type = :oneshot end self end |
#serialize ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/mnemosyne/span.rb', line 38 def serialize { uuid: uuid, name: name, type: type, start: start, stop: finish, meta: } end |