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.



75
76
77
78
79
80
81
# File 'lib/ablab.rb', line 75

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.



73
74
75
# File 'lib/ablab.rb', line 73

def callbacks
  @callbacks
end

#controlObject (readonly)

Returns the value of attribute control.



73
74
75
# File 'lib/ablab.rb', line 73

def control
  @control
end

#groupsObject (readonly)

Returns the value of attribute groups.



73
74
75
# File 'lib/ablab.rb', line 73

def groups
  @groups
end

#nameObject (readonly)

Returns the value of attribute name.



73
74
75
# File 'lib/ablab.rb', line 73

def name
  @name
end

Instance Method Details

#description(desc = nil) ⇒ Object



83
84
85
86
# File 'lib/ablab.rb', line 83

def description(desc = nil)
  @description = desc if desc
  @description
end

#goal(goal = nil) ⇒ Object



88
89
90
91
# File 'lib/ablab.rb', line 88

def goal(goal = nil)
  @goal = goal if goal
  @goal
end

#group(name, options = {}) ⇒ Object



98
99
100
101
# File 'lib/ablab.rb', line 98

def group(name, options = {})
  group = Group.new(name, options[:description])
  @groups << group
end

#on_track(&block) ⇒ Object



103
104
105
# File 'lib/ablab.rb', line 103

def on_track(&block)
  @callbacks << block
end

#percentage_of_visitors(percentage = nil) ⇒ Object



93
94
95
96
# File 'lib/ablab.rb', line 93

def percentage_of_visitors(percentage = nil)
  @percentage_of_visitors = percentage if percentage
  @percentage_of_visitors || 100
end

#resultsObject



107
108
109
110
# File 'lib/ablab.rb', line 107

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

#run(session_id, request) ⇒ Object



112
113
114
# File 'lib/ablab.rb', line 112

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