Class: Stream

Inherits:
Object
  • Object
show all
Defined in:
lib/cpee-logging-xes-yaml/tools.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Stream

Returns a new instance of Stream.



45
46
47
48
49
50
51
# File 'lib/cpee-logging-xes-yaml/tools.rb', line 45

def initialize(name)
  @name = name
  @id = nil
  @source = nil
  @meta = nil
  @values = []
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



42
43
44
# File 'lib/cpee-logging-xes-yaml/tools.rb', line 42

def id
  @id
end

#metaObject

Returns the value of attribute meta.



42
43
44
# File 'lib/cpee-logging-xes-yaml/tools.rb', line 42

def meta
  @meta
end

#nameObject (readonly)

Returns the value of attribute name.



43
44
45
# File 'lib/cpee-logging-xes-yaml/tools.rb', line 43

def name
  @name
end

#sourceObject

Returns the value of attribute source.



42
43
44
# File 'lib/cpee-logging-xes-yaml/tools.rb', line 42

def source
  @source
end

Instance Method Details

#<<(val) ⇒ Object



53
54
55
# File 'lib/cpee-logging-xes-yaml/tools.rb', line 53

def <<(val)
  @values << val
end

#to_listObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/cpee-logging-xes-yaml/tools.rb', line 57

def to_list
  tp = []
  tp << {'stream:name' => @name}
  tp << {'stream:id' => @id} unless @id.nil?
  tp << {'stream:source' => @source} unless @source.nil?
  tp << {'stream:meta' => @meta} unless @meta.nil?
  @values.each do |e|
    if e.is_a? Stream
      e.source = @source if e.source.nil? && !@source.nil?
      tp << { 'stream:datastream' => e.to_list }
    elsif e.is_a? StreamPoint
      e.source = @source if e.source.nil? && !@source.nil?
      tp << { 'stream:point' => e.to_h }
    end
  end
  tp
end