Class: Xcprofiler::Execution

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

Defined Under Namespace

Classes: Location

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time, location, method_name) ⇒ Execution

Returns a new instance of Execution.



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

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

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



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

def location
  @location
end

#method_nameObject (readonly)

Returns the value of attribute method_name.



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

def method_name
  @method_name
end

#timeObject (readonly)

Returns the value of attribute time.



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

def time
  @time
end

Instance Method Details

#columnObject



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

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

#filenameObject



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

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

#invalid?Boolean

Returns:

  • (Boolean)


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

def invalid?
  !location
end

#lineObject



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

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

#pathObject



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

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

#to_hObject



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

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