Sha256: 236b461c5be1534bf2f86f97f0e2dac876ba312ce1b38ef7b21464b02e4dc8c0

Contents?: true

Size: 777 Bytes

Versions: 9

Compression:

Stored size: 777 Bytes

Contents

module Split
  module DashboardHelpers
    def h(text)
      Rack::Utils.escape_html(text)
    end

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

    def path_prefix
      request.env['SCRIPT_NAME']
    end

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

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

    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 >= 2.58
        '99% confidence'
      elsif z >= 1.96
        '95% confidence'
      elsif z >= 1.65
        '90% confidence'
      else
        'Insufficient confidence'
      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
split-1.3.2 lib/split/dashboard/helpers.rb
split-1.3.1 lib/split/dashboard/helpers.rb
split-1.3.0 lib/split/dashboard/helpers.rb
split-1.2.1 lib/split/dashboard/helpers.rb
split-1.2.0 lib/split/dashboard/helpers.rb
split-1.1.0 lib/split/dashboard/helpers.rb
split-1.0.0 lib/split/dashboard/helpers.rb
split-0.8.0 lib/split/dashboard/helpers.rb
split-0.7.3 lib/split/dashboard/helpers.rb