Sha256: 98adc7be1a574a3b02a94282547a63f700569908644fcb5d441c80875a0db802

Contents?: true

Size: 745 Bytes

Versions: 5

Compression:

Stored size: 745 Bytes

Contents

module Split
  module DashboardHelpers
    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 == 0.0
        'No Change'
      elsif z < 1.96
        'no confidence'
      elsif z < 2.57
        '95% confidence'
      elsif z < 3.29
        '99% confidence'
      else
        '99.9% confidence'
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
split-0.4.6 lib/split/dashboard/helpers.rb
split-0.4.5 lib/split/dashboard/helpers.rb
split-0.4.4 lib/split/dashboard/helpers.rb
split-0.4.3 lib/split/dashboard/helpers.rb
split-0.4.2 lib/split/dashboard/helpers.rb