Class: Orocos::Log::LogMarker

Inherits:
Object
  • Object
show all
Defined in:
lib/orocos/log/log_marker.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time, type, index, comment) ⇒ LogMarker

Returns a new instance of LogMarker



34
35
36
37
38
39
# File 'lib/orocos/log/log_marker.rb', line 34

def initialize(time,type,index,comment)
    @time = time
    @type = type
    @index = index
    @comment = comment
end

Instance Attribute Details

#commentObject (readonly)

Returns the value of attribute comment



33
34
35
# File 'lib/orocos/log/log_marker.rb', line 33

def comment
  @comment
end

#indexObject (readonly)

Returns the value of attribute index



33
34
35
# File 'lib/orocos/log/log_marker.rb', line 33

def index
  @index
end

#timeObject (readonly)

Returns the value of attribute time



33
34
35
# File 'lib/orocos/log/log_marker.rb', line 33

def time
  @time
end

#typeObject (readonly)

Returns the value of attribute type



33
34
35
# File 'lib/orocos/log/log_marker.rb', line 33

def type
  @type
end

Class Method Details

.parse(samples) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/orocos/log/log_marker.rb', line 4

def self.parse(samples)
    markers = Array.new

    samples.each do |sample|
        if(sample.class.name != "/logger/Annotations")
            raise "Wrong annotions type: Expected \/logger\/Annotations but got #{sample.class.name}"
        end

        type = if(sample.key =~ /log_marker_(.*)$/)
                   $1.to_sym
               else
                   sample.key
               end
        index, comment = if(sample.value =~ /^<(.*)>;(.*)$/)
                             i = if $1 && !$1.empty?
                                    $1.to_i
                                 else
                                     0
                                 end
                             [i,$2]
                         else
                             [nil,sample.value]
                         end

        markers << LogMarker.new(sample.time,type,index||-1,comment)
    end
    markers 
end