Module: Trebuchet::Strategy::Percentable
- Includes:
- PerDenominationable
- Included in:
- Percent, VisitorPercent
- Defined in:
- lib/trebuchet/strategy.rb
Overview
Percentable module standardizes logic for percentage-based strategies
Instance Attribute Summary
Attributes included from PerDenominationable
Instance Method Summary collapse
- #export ⇒ Object
-
#set_range_from_options(options) ⇒ Object
must be called from initialize.
- #to_s ⇒ Object
Methods included from PerDenominationable
Instance Method Details
#export ⇒ Object
141 142 143 |
# File 'lib/trebuchet/strategy.rb', line 141 def export super(percentage) end |
#set_range_from_options(options) ⇒ Object
must be called from initialize
124 125 126 127 128 129 130 131 132 133 |
# File 'lib/trebuchet/strategy.rb', line 124 def () numerator = if == nil || .is_a?(Numeric) .to_i else 0 end super(numerator: numerator, denominator: 100) end |
#to_s ⇒ Object
135 136 137 138 139 |
# File 'lib/trebuchet/strategy.rb', line 135 def to_s kind = self.name == :visitor_percent ? "visitors" : "users" percentage_str = "#{percentage}% of #{kind}" "#{percentage_str}" end |