Class: Gitlab::Sherlock::FileSample

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/sherlock/file_sample.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, line_samples, duration, events) ⇒ FileSample

file - The full path to the file this sample belongs to. line_samples - An array of LineSample objects. duration - The total execution time in milliseconds. events - The total amount of events.


10
11
12
13
14
15
16
# File 'lib/gitlab/sherlock/file_sample.rb', line 10

def initialize(file, line_samples, duration, events)
  @id = SecureRandom.uuid
  @file = file
  @line_samples = line_samples
  @duration = duration
  @events = events
end

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration


4
5
6
# File 'lib/gitlab/sherlock/file_sample.rb', line 4

def duration
  @duration
end

#eventsObject (readonly)

Returns the value of attribute events


4
5
6
# File 'lib/gitlab/sherlock/file_sample.rb', line 4

def events
  @events
end

#fileObject (readonly)

Returns the value of attribute file


4
5
6
# File 'lib/gitlab/sherlock/file_sample.rb', line 4

def file
  @file
end

#idObject (readonly)

Returns the value of attribute id


4
5
6
# File 'lib/gitlab/sherlock/file_sample.rb', line 4

def id
  @id
end

#line_samplesObject (readonly)

Returns the value of attribute line_samples


4
5
6
# File 'lib/gitlab/sherlock/file_sample.rb', line 4

def line_samples
  @line_samples
end

Instance Method Details

#relative_pathObject


18
19
20
# File 'lib/gitlab/sherlock/file_sample.rb', line 18

def relative_path
  @relative_path ||= @file.gsub(/^#{Rails.root.to_s}\/?/, '')
end

#sourceObject


26
27
28
# File 'lib/gitlab/sherlock/file_sample.rb', line 26

def source
  @source ||= File.read(@file)
end

#to_paramObject


22
23
24
# File 'lib/gitlab/sherlock/file_sample.rb', line 22

def to_param
  @id
end