Class: Jiminy::Reporting::NPlusOne

Inherits:
Object
  • Object
show all
Defined in:
lib/jiminy/reporting/n_plus_one.rb

Constant Summary collapse

ERB_SAFE_LEVEL =
nil
TRIM_MODE =
"-"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file:, line:, method:, examples: []) ⇒ NPlusOne

Returns a new instance of NPlusOne.



17
18
19
20
21
22
# File 'lib/jiminy/reporting/n_plus_one.rb', line 17

def initialize(file:, line:, method:, examples: [])
  @examples = examples
  @file = file
  @line = line
  @method = method
end

Instance Attribute Details

#blob_urlObject

Returns the value of attribute blob_url.



15
16
17
# File 'lib/jiminy/reporting/n_plus_one.rb', line 15

def blob_url
  @blob_url
end

#examplesObject (readonly)

Returns the value of attribute examples.



13
14
15
# File 'lib/jiminy/reporting/n_plus_one.rb', line 13

def examples
  @examples
end

#fileObject (readonly)

Returns the value of attribute file.



13
14
15
# File 'lib/jiminy/reporting/n_plus_one.rb', line 13

def file
  @file
end

#lineObject (readonly)

Returns the value of attribute line.



13
14
15
# File 'lib/jiminy/reporting/n_plus_one.rb', line 13

def line
  @line
end

#methodObject (readonly)

Returns the value of attribute method.



13
14
15
# File 'lib/jiminy/reporting/n_plus_one.rb', line 13

def method
  @method
end

Instance Method Details

#blob_url_with_lineObject



28
29
30
# File 'lib/jiminy/reporting/n_plus_one.rb', line 28

def blob_url_with_line
  "#{blob_url}#L#{line}"
end

#to_markdownObject



24
25
26
# File 'lib/jiminy/reporting/n_plus_one.rb', line 24

def to_markdown
  ERB.new(markdown_template, trim_mode: TRIM_MODE).result(binding)
end