Class: LabTech::Summary::SpeedupLine

Inherits:
Object
  • Object
show all
Defined in:
app/models/lab_tech/summary/speedup_line.rb

Constant Summary collapse

VAL =
""
DOT =
"·"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(n, speedup_factors) ⇒ SpeedupLine

Returns a new instance of SpeedupLine.



10
11
12
13
# File 'app/models/lab_tech/summary/speedup_line.rb', line 10

def initialize(n, speedup_factors)
  @n               = n
  @speedup_factors = speedup_factors
end

Instance Attribute Details

#nObject (readonly)

Returns the value of attribute n.



8
9
10
# File 'app/models/lab_tech/summary/speedup_line.rb', line 8

def n
  @n
end

#speedup_factorsObject (readonly)

Returns the value of attribute speedup_factors.



8
9
10
# File 'app/models/lab_tech/summary/speedup_line.rb', line 8

def speedup_factors
  @speedup_factors
end

Instance Method Details

#to_sObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/models/lab_tech/summary/speedup_line.rb', line 15

def to_s
  highlight = ( n == 50 ) # Only 'highlight' (add dots to) the median line
  label = "%3d%%" % n

  speedup_factor = LabTech::Percentile.call(n, @speedup_factors)
  rel_speedup    = "%+.1fx" % speedup_factor
  bar            = normalized_bar( speedup_factor, speedup_magnitude, highlight: highlight)

  speedup_cue  = pad_left( rel_speedup, speedup_width )
  speedup_cue += " faster" if speedup_factor > 0

  "#{label}  #{bar}  #{speedup_cue}"
end