Class: StackTracy::EventInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/stack_tracy/event_info.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#eventObject (readonly)

Returns the value of attribute event.



7
8
9
# File 'lib/stack_tracy/event_info.rb', line 7

def event
  @event
end

#fileObject (readonly)

Returns the value of attribute file.



7
8
9
# File 'lib/stack_tracy/event_info.rb', line 7

def file
  @file
end

#lineObject (readonly)

Returns the value of attribute line.



7
8
9
# File 'lib/stack_tracy/event_info.rb', line 7

def line
  @line
end

#methodObject (readonly)

Returns the value of attribute method.



7
8
9
# File 'lib/stack_tracy/event_info.rb', line 7

def method
  @method
end

#nsecObject (readonly)

Returns the value of attribute nsec.



7
8
9
# File 'lib/stack_tracy/event_info.rb', line 7

def nsec
  @nsec
end

#objectObject (readonly)

Returns the value of attribute object.



7
8
9
# File 'lib/stack_tracy/event_info.rb', line 7

def object
  @object
end

#singletonObject (readonly)

Returns the value of attribute singleton.



7
8
9
# File 'lib/stack_tracy/event_info.rb', line 7

def singleton
  @singleton
end

Class Method Details

.to_hashes(csv) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/stack_tracy/event_info.rb', line 9

def self.to_hashes(csv)
  CSV.parse(csv.force_encoding("ISO-8859-1").encode("utf-8", {:replace => nil}), :headers => true, :col_sep => ";").collect do |row|
    {
      :event => row[0]     , :file => row[1]     , :line => row[2].to_i, :singleton => row[3] == "true", :object   => row[4]      , :method => row[5],
      :nsec  => row[6].to_f, :time => row[7].to_f, :call => row[8]     , :depth     => row[9].to_i     , :duration => row[10].to_f
    }
  end
end

Instance Method Details

#-(other) ⇒ Object



42
43
44
# File 'lib/stack_tracy/event_info.rb', line 42

def -(other)
  nsec - other.nsec if other.is_a? EventInfo
end

#callObject



53
54
55
56
57
58
59
# File 'lib/stack_tracy/event_info.rb', line 53

def call
  if method == "tracy" && object.is_a?(String)
    "\"#{object}\""
  else
    "#{object}#{singleton ? "." : "#"}#{method}"
  end
end

#call?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/stack_tracy/event_info.rb', line 18

def call?
  !!event.match(/call$/)
end

#matches?(arg) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/stack_tracy/event_info.rb', line 26

def matches?(arg)
  case arg.class.name
  when "StackTracy::EventInfo"
    matches? arg.call
  when "String"
    if call == arg
      true
    else
      captures = arg.match(/^([\w:]*\*?)?(\.|\#)?(\w*\*?)?$/).captures
      object_match?(captures[0]) && singleton_match?(captures[1]) && method_match?(captures[2])
    end
  else
    false
  end
end

#return?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/stack_tracy/event_info.rb', line 22

def return?
  !!event.match(/return$/)
end

#to_hash(first = nil) ⇒ Object



46
47
48
49
50
51
# File 'lib/stack_tracy/event_info.rb', line 46

def to_hash(first = nil)
  {
    :event => event, :file => file, :line => line, :singleton => singleton, :object => object,
    :method => method, :nsec => nsec, :time => (first ? self - first : nil), :call => call
  }
end