Class: Ablab::Experiment

Inherits:
Object
  • Object
show all
Defined in:
lib/ablab.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#callbacksObject (readonly)

Returns the value of attribute callbacks.



75
76
77
# File 'lib/ablab.rb', line 75

def callbacks
  @callbacks
end

#controlObject (readonly)

Returns the value of attribute control.



75
76
77
# File 'lib/ablab.rb', line 75

def control
  @control
end

#groupsObject (readonly)

Returns the value of attribute groups.



75
76
77
# File 'lib/ablab.rb', line 75

def groups
  @groups
end

#nameObject (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, options = {})
  group = Group.new(name, options[:description], options[: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

#resultsObject



109
110
111
112
# File 'lib/ablab.rb', line 109

def results
  @result ||= Result.new(self)
  @result.data
end

#run(session_id, request) ⇒ Object



114
115
116
# File 'lib/ablab.rb', line 114

def run(session_id, request)
  Run.new(self, session_id, request)
end