Class: XES::Document

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

Overview

Document is a class for XES event log doucment.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(log = nil) ⇒ Document

Returns a new instance of Document.

Parameters:

  • log (Log) (defaults to: nil)


9
10
11
# File 'lib/xes/document.rb', line 9

def initialize(log=nil)
  @log = log
end

Instance Attribute Details

#logLog

Returns log element.

Returns:

  • (Log)

    log element



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

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



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

def ==(other)
  return false unless other.kind_of?(self.class)
  @log == other.log
end

#formatREXML::Document

Format as a XML document.

Returns:

  • (REXML::Document)

    XML document

Raises:

  • FormatError format error when the document is not formattable



27
28
29
30
31
32
33
34
# File 'lib/xes/document.rb', line 27

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

  REXML::Document.new.tap do |doc|
    doc << REXML::XMLDecl.new
    doc.elements << @log.format
  end
end

#formattable?Boolean

Return true if the document is formattable.

Returns:

  • (Boolean)

    true if the element is formattable



17
18
19
# File 'lib/xes/document.rb', line 17

def formattable?
  not(@log.nil?) and @log.formattable?
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.



44
45
46
# File 'lib/xes/document.rb', line 44

def hash
  @attributes.hash + @events.hash
end