Class: Kameleoon::Targeting::VisitNumberTodayCondition Private
- Inherits:
-
NumberCondition
- Object
- Condition
- NumberCondition
- Kameleoon::Targeting::VisitNumberTodayCondition
- Defined in:
- lib/kameleoon/targeting/conditions/visit_number_today_condition.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: TargetingData
Instance Attribute Summary
Attributes inherited from Condition
Instance Method Summary collapse
- #check(data) ⇒ Object private
-
#initialize(json_condition) ⇒ VisitNumberTodayCondition
constructor
private
A new instance of VisitNumberTodayCondition.
Constructor Details
#initialize(json_condition) ⇒ VisitNumberTodayCondition
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of VisitNumberTodayCondition.
10 11 12 13 |
# File 'lib/kameleoon/targeting/conditions/visit_number_today_condition.rb', line 10 def initialize(json_condition) visit_count = json_condition['visitCount'] super(json_condition, visit_count) end |
Instance Method Details
#check(data) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/kameleoon/targeting/conditions/visit_number_today_condition.rb', line 15 def check(data) return false unless data.is_a?(TargetingData) && !@condition_value.nil? number_of_visits_today = 0 start_of_day = (Time.new.to_date.to_time.to_f * 1000).to_i # ... * 1000 to convert seconds to milliseconds data.visitor_visits.prev_visits.each do |visit| break if visit.time_started < start_of_day number_of_visits_today += 1 end number_of_visits_today += 1 if data.current_visit_time_started >= start_of_day check_targeting(number_of_visits_today) end |