Class: XES::Classifier

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

Overview

Classifier represents “classifier” element of XES.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, keys) ⇒ Classifier

Create a XES classifier element.

Parameters:

  • name (String)

    classifier name

  • keys (String)

    classifier keys



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

def initialize(name, keys)
  @name = name
  @keys = keys
end

Instance Attribute Details

#keysString (readonly)

Returns classifier keys.

Returns:

  • (String)

    classifier keys



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

def keys
  @keys
end

#nameString (readonly)

Returns classifier name.

Returns:

  • (String)

    classifier name



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

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



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

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

#formatREXML::Element

Format as a XML element.

Returns:

  • (REXML::Element)

    XML element

Raises:



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

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

  REXML::Element.new("classifier").tap do |ext|
    ext.attributes["name"] = @name
    ext.attributes["keys"] = @keys
  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/classifier.rb', line 27

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



52
53
54
# File 'lib/xes/classifier.rb', line 52

def hash
  @name.hash + @keys.hash
end