Class: Fino::AbTesting::Variant

Inherits:
Object
  • Object
show all
Includes:
PrettyInspectable
Defined in:
lib/fino/ab_testing/variant.rb

Constant Summary collapse

CONTROL_VALUE =
Class.new do
  def inspect
    "Fino::AbTesting::Variant::CONTROL_VALUE"
  end

  def to_s
    "control"
  end
end.new

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PrettyInspectable

#inspect, #pretty_print

Constructor Details

#initialize(percentage:, value:) ⇒ Variant

Returns a new instance of Variant.



18
19
20
21
# File 'lib/fino/ab_testing/variant.rb', line 18

def initialize(percentage:, value:)
  @percentage = percentage.to_f
  @value = value
end

Instance Attribute Details

#percentageObject (readonly)

Returns the value of attribute percentage.



16
17
18
# File 'lib/fino/ab_testing/variant.rb', line 16

def percentage
  @percentage
end

#valueObject (readonly)

Returns the value of attribute value.



16
17
18
# File 'lib/fino/ab_testing/variant.rb', line 16

def value
  @value
end

Instance Method Details

#idObject



23
24
25
# File 'lib/fino/ab_testing/variant.rb', line 23

def id
  "#{percentage}-#{value}"
end