lib/vanity/experiment/alternative.rb in vanity-3.1.0 vs lib/vanity/experiment/alternative.rb in vanity-4.0.0

- old
+ new

@@ -1,15 +1,13 @@ module Vanity module Experiment - # One of several alternatives in an A/B test (see AbTest#alternatives). class Alternative - - def initialize(experiment, id, value) #, participants, converted, conversions) + def initialize(experiment, id, value) # , participants, converted, conversions) @experiment = experiment @id = id - @name = I18n.t('vanity.option_number', :char=>(@id + 65).chr.upcase) + @name = I18n.t('vanity.option_number', char: (@id + 65).chr.upcase) @value = value end # Alternative id, only unique for this experiment. attr_reader :id @@ -54,10 +52,10 @@ # AbTest#score. attr_accessor :difference # Conversion rate calculated as converted/participants def conversion_rate - @conversion_rate ||= (participants > 0 ? converted.to_f/participants.to_f : 0.0) + @conversion_rate ||= (participants > 0 ? converted.to_f / participants : 0.0) end # The measure we use to order (sort) alternatives and decide which one # is better (by calculating z-score). Defaults to conversion rate. def measure