Class: Rack::Lineprof::Sample

Inherits:
Struct
  • Object
show all
Defined in:
lib/rack/lineprof/sample.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#callsObject

Returns the value of attribute calls

Returns:

  • (Object)

    the current value of calls



3
4
5
# File 'lib/rack/lineprof/sample.rb', line 3

def calls
  @calls
end

#codeObject

Returns the value of attribute code

Returns:

  • (Object)

    the current value of code



3
4
5
# File 'lib/rack/lineprof/sample.rb', line 3

def code
  @code
end

#levelObject

Returns the value of attribute level

Returns:

  • (Object)

    the current value of level



3
4
5
# File 'lib/rack/lineprof/sample.rb', line 3

def level
  @level
end

#lineObject

Returns the value of attribute line

Returns:

  • (Object)

    the current value of line



3
4
5
# File 'lib/rack/lineprof/sample.rb', line 3

def line
  @line
end

#msObject

Returns the value of attribute ms

Returns:

  • (Object)

    the current value of ms



3
4
5
# File 'lib/rack/lineprof/sample.rb', line 3

def ms
  @ms
end

Instance Method Details

#format(colorize = true) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rack/lineprof/sample.rb', line 5

def format colorize = true
  formatted = if level == CONTEXT
    sprintf "               | % 3i  %s", line, code
  else
    sprintf "% 6.1fms %5i | % 3i  %s", ms, calls, line, code
  end

  return formatted unless colorize

  case level
  when CRITICAL
    color.red formatted
  when WARNING
    color.yellow formatted
  when NOMINAL
    color.white formatted
  else # CONTEXT
    color.intense_black formatted
  end
end