Class: Trebuchet::Strategy::VisitorPercent

Inherits:
Base
  • Object
show all
Includes:
Percentable
Defined in:
lib/trebuchet/strategy/visitor_percent.rb

Instance Attribute Summary

Attributes included from PerDenominationable

#denominator, #numerator

Attributes inherited from Base

#feature

Instance Method Summary collapse

Methods included from Percentable

#export, #set_range_from_options, #to_s

Methods included from PerDenominationable

#export, #set_range_from_options, #to_s, #value_in_range?

Methods inherited from Base

#as_json, #export, #feature_id, #inspect, #name, strategy_name

Constructor Details

#initialize(options) ⇒ VisitorPercent

Returns a new instance of VisitorPercent.



5
6
7
# File 'lib/trebuchet/strategy/visitor_percent.rb', line 5

def initialize(options)
  set_range_from_options(options)
end

Instance Method Details

#launch_at?(user, request = nil) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
17
18
# File 'lib/trebuchet/strategy/visitor_percent.rb', line 9

def launch_at?(user, request = nil)
  return false if request.nil?
  if Trebuchet.visitor_id.respond_to?(:call)
    visitor_id = Trebuchet.visitor_id.call(request)
  else
    visitor_id = nil
  end
  return false if visitor_id.nil?
  value_in_range?(visitor_id.to_i)
end

#needs_user?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/trebuchet/strategy/visitor_percent.rb', line 20

def needs_user?
  false
end