Class: XES::Attribute

Inherits:
Object
  • Object
show all
Extended by:
AttributeAccessor
Defined in:
lib/xes/attribute.rb

Overview

Attribute represents attribute of XES.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AttributeAccessor

define_attribute

Constructor Details

#initialize(type, key, value, meta = []) ⇒ Attribute

Returns a new instance of Attribute.

Parameters:

  • type (String)

    attribute type

  • key (String)

    attribute name

  • value (String)

    attribute value

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

    meta attributes



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

def initialize(type, key, value, meta=[])
  @type = type
  @key = key
  @value = value
  @meta = meta
end

Instance Attribute Details

#cost_amountFloat

Returns the value of meta attribute “cost:amount”.

Returns:

  • (Float)

    the value of meta attribute “cost:amount”



19
# File 'lib/xes/attribute.rb', line 19

define_attribute "cost:amount", "float"

#cost_driverString

Returns the value of meta attribute “cost:driver”.

Returns:

  • (String)

    the value of meta attribute “cost:driver”



24
# File 'lib/xes/attribute.rb', line 24

define_attribute "cost:driver", "string"

#cost_typeString

Returns the value of meta attribute “cost:type”.

Returns:

  • (String)

    the value of meta attribute “cost:type”



29
# File 'lib/xes/attribute.rb', line 29

define_attribute "cost:type", "string"

#identity_idString

Returns the value of meta attribute “identity:id”.

Returns:

  • (String)

    the value of meta attribute “identity:id”



14
# File 'lib/xes/attribute.rb', line 14

define_attribute "identity:id", "id"

#keyString

Returns attribute name.

Returns:

  • (String)

    attribute name



37
38
39
# File 'lib/xes/attribute.rb', line 37

def key
  @key
end

#metaMeta

Returns attribute meta attributes.

Returns:

  • (Meta)

    attribute meta attributes



45
46
47
# File 'lib/xes/attribute.rb', line 45

def meta
  @meta
end

#semantic_modelReferenceString

Returns the value of meta attribute “semantic:modelReference”.

Returns:

  • (String)

    the value of meta attribute “semantic:modelReference”



9
# File 'lib/xes/attribute.rb', line 9

define_attribute "semantic:modelReference", "string"

#typeString (readonly)

Returns attribute type.

Returns:

  • (String)

    attribute type



33
34
35
# File 'lib/xes/attribute.rb', line 33

def type
  @type
end

#valueString

Returns attribute value.

Returns:

  • (String)

    attribute value



41
42
43
# File 'lib/xes/attribute.rb', line 41

def value
  @value
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.



82
83
84
85
# File 'lib/xes/attribute.rb', line 82

def ==(other)
  return false unless other.kind_of?(self.class)
  @type == other.type and @key == other.key and @value == other.value and @meta == other.meta
end

#formatObject

Format as a XML element.

Raises:



71
72
73
74
75
76
77
78
79
# File 'lib/xes/attribute.rb', line 71

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

  REXML::Element.new(type).tap do |attribute|
    attribute.attributes["key"] = @key
    attribute.attributes["value"] = format_value
    meta.each {|m| attribute.elements << m.format if m.formattable?}
  end
end

#formattable?Boolean

Return true if the element is formattable.

Returns:

  • (Boolean)

    true if the element is formattable



66
67
68
# File 'lib/xes/attribute.rb', line 66

def formattable?
  not(@type.nil? or @key.nil? or @value.nil? or @meta.nil?)
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.



89
90
91
# File 'lib/xes/attribute.rb', line 89

def hash
  @type.hash + @key.hash + @value.hash
end