Class: Ablab::Experiment
- Inherits:
-
Object
- Object
- Ablab::Experiment
- Defined in:
- lib/ablab.rb
Instance Attribute Summary collapse
-
#callbacks ⇒ Object
readonly
Returns the value of attribute callbacks.
-
#control ⇒ Object
readonly
Returns the value of attribute control.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #description(desc = nil) ⇒ Object
- #goal(goal = nil) ⇒ Object
- #group(name, options = {}) ⇒ Object
-
#initialize(name, &block) ⇒ Experiment
constructor
A new instance of Experiment.
- #on_track(&block) ⇒ Object
- #percentage_of_visitors(percentage = nil) ⇒ Object
- #results ⇒ Object
- #run(session_id, request) ⇒ Object
Constructor Details
#initialize(name, &block) ⇒ Experiment
Returns a new instance of Experiment.
77 78 79 80 81 82 83 |
# File 'lib/ablab.rb', line 77 def initialize(name, &block) @name = name.to_sym @control = Group.new(:control, 'control group') @groups = [@control] @callbacks = [] instance_exec(&block) end |
Instance Attribute Details
#callbacks ⇒ Object (readonly)
Returns the value of attribute callbacks.
75 76 77 |
# File 'lib/ablab.rb', line 75 def callbacks @callbacks end |
#control ⇒ Object (readonly)
Returns the value of attribute control.
75 76 77 |
# File 'lib/ablab.rb', line 75 def control @control end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
75 76 77 |
# File 'lib/ablab.rb', line 75 def groups @groups end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
75 76 77 |
# File 'lib/ablab.rb', line 75 def name @name end |
Instance Method Details
#description(desc = nil) ⇒ Object
85 86 87 88 |
# File 'lib/ablab.rb', line 85 def description(desc = nil) @description = desc if desc @description end |
#goal(goal = nil) ⇒ Object
90 91 92 93 |
# File 'lib/ablab.rb', line 90 def goal(goal = nil) @goal = goal if goal @goal end |
#group(name, options = {}) ⇒ Object
100 101 102 103 |
# File 'lib/ablab.rb', line 100 def group(name, = {}) group = Group.new(name, [:description], [:weight]) @groups << group end |
#on_track(&block) ⇒ Object
105 106 107 |
# File 'lib/ablab.rb', line 105 def on_track(&block) @callbacks << block end |
#percentage_of_visitors(percentage = nil) ⇒ Object
95 96 97 98 |
# File 'lib/ablab.rb', line 95 def percentage_of_visitors(percentage = nil) @percentage_of_visitors = percentage if percentage @percentage_of_visitors || 100 end |