Class: Xctracker::Execution

Inherits:
Object
  • Object
show all
Defined in:
lib/xctracker/execution.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time, position, method_name) ⇒ Execution

Returns a new instance of Execution.



7
8
9
10
11
12
13
14
# File 'lib/xctracker/execution.rb', line 7

def initialize(time, position, method_name)
  @time = time.to_f
  unless position =~ /<invalid loc>/
    path, line, column = position.split(':')
    @position = Struct::Position.new(path, line.to_i, column.to_i)
  end
  @method_name = method_name
end

Instance Attribute Details

#method_nameObject (readonly)

Returns the value of attribute method_name.



5
6
7
# File 'lib/xctracker/execution.rb', line 5

def method_name
  @method_name
end

#positionObject (readonly)

Returns the value of attribute position.



5
6
7
# File 'lib/xctracker/execution.rb', line 5

def position
  @position
end

#timeObject (readonly)

Returns the value of attribute time.



5
6
7
# File 'lib/xctracker/execution.rb', line 5

def time
  @time
end

Instance Method Details

#columnObject



46
47
48
49
50
51
52
# File 'lib/xctracker/execution.rb', line 46

def column
  if @position
    @position.column
  else
    nil
  end
end

#filenameObject



38
39
40
41
42
43
44
# File 'lib/xctracker/execution.rb', line 38

def filename
  if path
    File.basename(path)
  else
    nil
  end
end

#invalid?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/xctracker/execution.rb', line 26

def invalid?
  !position
end

#lineObject



54
55
56
57
58
59
60
# File 'lib/xctracker/execution.rb', line 54

def line
  if @position
    @position.line
  else
    nil
  end
end

#pathObject



30
31
32
33
34
35
36
# File 'lib/xctracker/execution.rb', line 30

def path
  if @position
    @position.path
  else
    nil
  end
end

#to_hObject



16
17
18
19
20
21
22
23
24
# File 'lib/xctracker/execution.rb', line 16

def to_h
  {
    method_name: method_name,
    time: time,
    path: path,
    line: line,
    column: column
  }
end