Class: XES::Extension

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

Overview

Extension represents “extension” element of XES.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, prefix, uri) ⇒ Extension

Create a XES extension element.

Parameters:

  • name (String)

    extension name

  • prefix (String)

    extension prefix

  • uri (String)

    extension definition URI



24
25
26
27
28
# File 'lib/xes/extension.rb', line 24

def initialize(name, prefix, uri)
  @name = name
  @prefix = prefix
  @uri = uri
end

Instance Attribute Details

#nameString (readonly)

Returns extension name.

Returns:

  • (String)

    extension name



6
7
8
# File 'lib/xes/extension.rb', line 6

def name
  @name
end

#prefixString (readonly)

Returns extension prefix.

Returns:

  • (String)

    extension prefix



10
11
12
# File 'lib/xes/extension.rb', line 10

def prefix
  @prefix
end

#uriString (readonly)

Returns extension URI.

Returns:

  • (String)

    extension URI



14
15
16
# File 'lib/xes/extension.rb', line 14

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



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

def ==(other)
  return false unless other.kind_of?(self.class)
  @name == other.name and @prefix == other.prefix and @uri == other.uri
end

#formatREXML::Element

Format as a XML element.

Returns:

  • (REXML::Element)

    XML element

Raises:



42
43
44
45
46
47
48
49
50
# File 'lib/xes/extension.rb', line 42

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

  REXML::Element.new("extension").tap do |ext|
    ext.attributes["name"] = @name
    ext.attributes["prefix"] = @prefix
    ext.attributes["uri"] = @uri
  end
end

#formattable?Boolean

Return true if the element is formattable.

Returns:

  • (Boolean)

    true if the element is formattable



34
35
36
# File 'lib/xes/extension.rb', line 34

def formattable?
  not(@name.nil? or @prefix.nil? or @uri.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.



60
61
62
# File 'lib/xes/extension.rb', line 60

def hash
  @name.hash + @prefix.hash + @uri.hash
end