class Ab::Test
Constants
- DEFAULT_END_AT
- DEFAULT_START_AT
Public Instance Methods
all_buckets?()
click to toggle source
# File lib/ab/test.rb, line 10 def all_buckets? hash['all_buckets'] end
buckets()
click to toggle source
# File lib/ab/test.rb, line 6 def buckets hash['buckets'] end
end_at()
click to toggle source
# File lib/ab/test.rb, line 35 def end_at @end_at ||= parse_time('end_at', DEFAULT_END_AT) end
name()
click to toggle source
# File lib/ab/test.rb, line 14 def name hash['name'] end
seed()
click to toggle source
# File lib/ab/test.rb, line 27 def seed hash['seed'] end
start_at()
click to toggle source
# File lib/ab/test.rb, line 31 def start_at @start_at ||= parse_time('start_at', DEFAULT_START_AT) end
variants()
click to toggle source
# File lib/ab/test.rb, line 18 def variants @variants ||= begin accumulated = 0 hash['variants'].map do |variant_hash| Variant.new(variant_hash, accumulated += variant_hash['chance_weight']) end end end
weight_sum()
click to toggle source
# File lib/ab/test.rb, line 39 def weight_sum variants.map(&:chance_weight).inject(:+) end
Private Instance Methods
parse_time(name, default)
click to toggle source
# File lib/ab/test.rb, line 45 def parse_time(name, default) value = hash[name] value.nil? ? default : DateTime.parse(value) end