class Growthbook::ExperimentResult

Attributes

data[R]

The data tied to the chosen variation @return [Hash]

experiment[R]

The experiment that was performed @return [Growthbook::Experiment, nil] If nil, then the experiment with the required id could not be found

user[R]

The user that was experimented on @return [Growthbook::User]

variation[R]

The chosen variation. -1 for “not in experiment”, 0 for control, 1 for 1st variation, etc. @return [Integer]

Public Class Methods

new(user = nil, experiment = nil, variation = -1, forced = false) click to toggle source
# File lib/growthbook/experiment_result.rb, line 29
def initialize(user = nil, experiment = nil, variation = -1, forced = false)
  @experiment = experiment
  @variation = variation
  @forced = forced

  @data = {}
  if experiment && experiment.data
    var = variation < 0 ? 0 : variation
    experiment.data.each do |k, v|
      @data[k] = v[var]
    end
  end
end

Public Instance Methods

forced?() click to toggle source
# File lib/growthbook/experiment_result.rb, line 21
def forced?
  @forced
end
shouldTrack?() click to toggle source
# File lib/growthbook/experiment_result.rb, line 25
def shouldTrack?
  !@forced && @variation >= 0
end