Class: XES::Global

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

Overview

Global represents “global” element of XES.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope, attributes = []) ⇒ Global

Returns a new instance of Global.

Parameters:

  • scope (String)

    scope of global attributes

  • attributes (Arrray<Attribute>) (defaults to: [])

    global attributes



38
39
40
41
# File 'lib/xes/global.rb', line 38

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

Instance Attribute Details

#attributesArray<Attribute>

Returns global attributes.

Returns:



32
33
34
# File 'lib/xes/global.rb', line 32

def attributes
  @attributes
end

#scopeString (readonly)

Returns scope name.

Returns:

  • (String)

    scope name



28
29
30
# File 'lib/xes/global.rb', line 28

def scope
  @scope
end

Class Method Details

.event(attributes = []) ⇒ Object

Create an event global. The object extended by EventAttributeAccessor.

Parameters:

  • attributes (Array<Attribute>) (defaults to: [])

    event global attributes



9
10
11
12
13
# File 'lib/xes/global.rb', line 9

def event(attributes=[])
  new("event", attributes).tap do |global|
    global.extend EventAttributeAccessor
  end
end

.trace(attributes = []) ⇒ Object

Create a trace global. The object extended by TraceAttributeAccessor.

Parameters:

  • attributes (Array<Attribute>) (defaults to: [])

    trace global attributes



19
20
21
22
23
# File 'lib/xes/global.rb', line 19

def trace(attributes=[])
  new("trace", attributes).tap do |global|
    global.extend TraceAttributeAccessor
  end
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.



65
66
67
# File 'lib/xes/global.rb', line 65

def ==(other)
  @scope == other.scope and @attributes == other.attributes
end

#formatREXML::Element

Format as a XML element.

Returns:

  • (REXML::Element)

    XML element

Raises:



55
56
57
58
59
60
61
62
# File 'lib/xes/global.rb', line 55

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

  REXML::Element.new("global").tap do |global|
    global.attributes["scope"] = @scope.to_s
    @attributes.each {|attribute| global.elements << attribute.format}
  end
end

#formattable?Boolean

Return true if the element is formattable.

Returns:

  • (Boolean)

    true if the element is formattable



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

def formattable?
  not(@attributes.empty?)
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.



71
72
73
# File 'lib/xes/global.rb', line 71

def hash
  @scope.hash + @attributes.hash
end