Class: Modesty::Experiment::Interface

Inherits:
Object
  • Object
show all
Defined in:
lib/modesty/experiment/interface.rb

Overview

the thing yielded when you say ‘Modesty.experiment :foo do |e| …`

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exp, identity) ⇒ Interface

Returns a new instance of Interface.



5
6
7
8
# File 'lib/modesty/experiment/interface.rb', line 5

def initialize(exp, identity)
  @exp = exp
  @alt = exp.group(identity)
end

Instance Attribute Details

#last_valueObject (readonly)

Returns the value of attribute last_value.



10
11
12
# File 'lib/modesty/experiment/interface.rb', line 10

def last_value
  @last_value
end

Instance Method Details

#group(gr = nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/modesty/experiment/interface.rb', line 12

def group(gr=nil)
  if block_given?
    if gr && @exp.group == gr
      @last_value = yield
    else
      @last_value
    end
  else
    @exp.group
  end
end

#group?(alt) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/modesty/experiment/interface.rb', line 24

def group?(alt)
  alt == @alt
end