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.



51
52
53
54
55
56
# File 'lib/ablab.rb', line 51

def initialize(name, &block)
  @name    = name.to_sym
  @control = Group.new(:control, 'control group')
  @groups  = [@control]
  instance_exec(&block)
end

Instance Attribute Details

#controlObject (readonly)

Returns the value of attribute control.



49
50
51
# File 'lib/ablab.rb', line 49

def control
  @control
end

#groupsObject (readonly)

Returns the value of attribute groups.



49
50
51
# File 'lib/ablab.rb', line 49

def groups
  @groups
end

#nameObject (readonly)

Returns the value of attribute name.



49
50
51
# File 'lib/ablab.rb', line 49

def name
  @name
end

Instance Method Details

#description(desc = nil) ⇒ Object



58
59
60
61
# File 'lib/ablab.rb', line 58

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

#goal(goal = nil) ⇒ Object



63
64
65
66
# File 'lib/ablab.rb', line 63

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

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



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

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

#percentage_of_visitors(percentage = nil) ⇒ Object



68
69
70
71
# File 'lib/ablab.rb', line 68

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

#resultsObject



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

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

#run(session_id) ⇒ Object



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

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