Class: Sidekiq::Portal::Timeline Private

Inherits:
Object
  • Object
show all
Defined in:
lib/portal/timeline.rb

Overview

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.

Since:

  • 0.1.0

Defined Under Namespace

Modules: Builder

Instance Method Summary collapse

Constructor Details

#initialize(initial_time, timezoner, time_plan) ⇒ void

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.

Parameters:

  • initial_time (Time)
  • timezoner (ActiveSupport::TimeZone)
  • time_plan (Fugit::Duration, Fugit::Cron)

Since:

  • 0.1.0



15
16
17
18
19
20
# File 'lib/portal/timeline.rb', line 15

def initialize(initial_time, timezoner, time_plan)
  @timezoner = timezoner
  @time_plan = time_plan
  @internal_time = initial_time
  @lock = Sidekiq::Portal::Lock.new
end

Instance Method Details

#actualize_time!void

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.

This method returns an undefined value.

Since:

  • 0.1.0



26
27
28
# File 'lib/portal/timeline.rb', line 26

def actualize_time!
  @internal_time = next_time_point
end

#current_time_pointTime

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:

  • (Time)

Since:

  • 0.1.0



34
35
36
# File 'lib/portal/timeline.rb', line 34

def current_time_point
  thread_safe { timezoner.at(internal_time) }
end

#next_time_pointTime

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:

  • (Time)

Since:

  • 0.1.0



42
43
44
# File 'lib/portal/timeline.rb', line 42

def next_time_point
  thread_safe { timezoner.at(time_plan.next_time(current_time_point).seconds) }
end

#time_has_come?Boolean

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:

  • (Boolean)

Since:

  • 0.1.0



71
72
73
# File 'lib/portal/timeline.rb', line 71

def time_has_come?
  thread_safe { global_time_point >= next_time_point }
end

#time_pointsArray<Time>

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.

Parameters:

  • target_time (Time)

Returns:

  • (Array<Time>)

Since:

  • 0.1.0



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/portal/timeline.rb', line 51

def time_points
  thread_safe do
    start_time  = current_time_point
    target_time = global_time_point

    [].tap do |future_points|
      while start_time <= target_time
        future_point = timezoner.at(time_plan.next_time(start_time).seconds)
        next if start_time > future_point
        future_points.push(future_point)
        start_time = future_point
      end
    end
  end
end