class Growthbook::LookupResult

Attributes

data[R]

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

experiment[R]

The first matching experiment @return [Growthbook::Experiment]

value[R]

The value of the data key that was used to lookup the experiment

variation[R]

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

Public Class Methods

new(result, key) click to toggle source
# File lib/growthbook/lookup_result.rb, line 28
def initialize(result, key)
  @experiment = result.experiment
  @variation = result.variation
  @forced = result.forced?

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

  @value = @data[key] || nil
end

Public Instance Methods

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