Class: XES::Global
- Inherits:
-
Object
- Object
- XES::Global
- Defined in:
- lib/xes/global.rb
Overview
Global represents “global” element of XES.
Instance Attribute Summary collapse
-
#attributes ⇒ Array<Attribute>
Global attributes.
-
#scope ⇒ String
readonly
Scope name.
Class Method Summary collapse
-
.event(attributes = []) ⇒ Object
Create an event global.
-
.trace(attributes = []) ⇒ Object
Create a trace global.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?) private
-
#format ⇒ REXML::Element
Format as a XML element.
-
#formattable? ⇒ Boolean
Return true if the element is formattable.
- #hash ⇒ Object private
-
#initialize(scope, attributes = []) ⇒ Global
constructor
A new instance of Global.
Constructor Details
#initialize(scope, attributes = []) ⇒ Global
Returns a new instance of Global.
38 39 40 41 |
# File 'lib/xes/global.rb', line 38 def initialize(scope, attributes=[]) @scope = scope @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Array<Attribute>
Returns global attributes.
32 33 34 |
# File 'lib/xes/global.rb', line 32 def attributes @attributes end |
#scope ⇒ String (readonly)
Returns 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.
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.
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 |
#format ⇒ REXML::Element
Format as a XML element.
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.
47 48 49 |
# File 'lib/xes/global.rb', line 47 def formattable? not(@attributes.empty?) end |
#hash ⇒ Object
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 |