Class: XES::Trace

Inherits:
Object
  • Object
show all
Includes:
TraceAttributeAccessor
Defined in:
lib/xes/trace.rb

Overview

Trace represents “trace” element of XES.

Instance Attribute Summary collapse

Attributes included from TraceAttributeAccessor

#concept_name, #cost:total, #cost_currency, #identity_id, #semantic_modelReference

Instance Method Summary collapse

Methods included from AttributeAccessor

#define_attribute

Constructor Details

#initialize(attributes = [], events = []) ⇒ Trace

Create a XES trace.

Parameters:

  • events (Array<Event>) (defaults to: [])

    events included in the trace element



18
19
20
21
# File 'lib/xes/trace.rb', line 18

def initialize(attributes=[], events=[])
  @attributes = attributes
  @events = events
end

Instance Attribute Details

#attributesArray<Attribute>

Returns attributes of the trace element.

Returns:

  • (Array<Attribute>)

    attributes of the trace element



8
9
10
# File 'lib/xes/trace.rb', line 8

def attributes
  @attributes
end

#eventsArray<Event>

Returns events included in the trace element.

Returns:

  • (Array<Event>)

    events included in the trace element



12
13
14
# File 'lib/xes/trace.rb', line 12

def events
  @events
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



46
47
48
49
# File 'lib/xes/trace.rb', line 46

def ==(other)
  return false unless other.kind_of?(self.class)
  @attributes == other.attributes and @events == other.events
end

#formatREXML::Element

Format as a XML element.

Returns:

  • (REXML::Element)

    XML element

Raises:

  • FormatError



36
37
38
39
40
41
42
43
# File 'lib/xes/trace.rb', line 36

def format
  raise FormatError.new(self) unless formattable?

  REXML::Element.new("trace").tap do |trace|
    @attributes.each {|attribute| trace.elements << attribute.format if attribute.formattable?}
    @events.each {|event| trace.elements << event.format if event.formattable?}
  end
end

#formattable?Boolean

Return true if the element is formattable.

Returns:

  • (Boolean)

    true if the element is formattable



27
28
29
# File 'lib/xes/trace.rb', line 27

def formattable?
  @events.any? {|event| event.formattable?}
end

#hashObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



53
54
55
# File 'lib/xes/trace.rb', line 53

def hash
  @attributes.hash + @events.hash
end