Module: Split::DashboardHelpers

Defined in:
lib/split/dashboard/helpers.rb

Instance Method Summary collapse

Instance Method Details

#confidence_level(z_score) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/split/dashboard/helpers.rb', line 19

def confidence_level(z_score)
  return z_score if z_score.is_a? String

  z = round(z_score.to_s.to_f, 3).abs

  if z == 0.0
    'No Change'
  elsif z < 1.645
    'no confidence'
  elsif z < 1.96
    '95% confidence'
  elsif z < 2.57
    '99% confidence'
  else
    '99.9% confidence'
  end
end

#number_to_percentage(number, precision = 2) ⇒ Object



11
12
13
# File 'lib/split/dashboard/helpers.rb', line 11

def number_to_percentage(number, precision = 2)
  round(number * 100)
end

#path_prefixObject



7
8
9
# File 'lib/split/dashboard/helpers.rb', line 7

def path_prefix
  request.env['SCRIPT_NAME']
end

#round(number, precision = 2) ⇒ Object



15
16
17
# File 'lib/split/dashboard/helpers.rb', line 15

def round(number, precision = 2)
  BigDecimal.new(number.to_s).round(precision).to_f
end

#url(*path_parts) ⇒ Object



3
4
5
# File 'lib/split/dashboard/helpers.rb', line 3

def url(*path_parts)
  [ path_prefix, path_parts ].join("/").squeeze('/')
end