Class: Leafy::Core::ScheduledReporter::ReportedTask
- Inherits:
-
Object
- Object
- Leafy::Core::ScheduledReporter::ReportedTask
- Defined in:
- lib/leafy/core/scheduled_reporter.rb
Instance Attribute Summary collapse
-
#period ⇒ Object
readonly
Returns the value of attribute period.
Instance Method Summary collapse
- #call ⇒ Object
- #delay ⇒ Object
-
#initialize(reporter, start, period) ⇒ ReportedTask
constructor
A new instance of ReportedTask.
- #task(task = nil) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(reporter, start, period) ⇒ ReportedTask
Returns a new instance of ReportedTask.
37 38 39 40 41 |
# File 'lib/leafy/core/scheduled_reporter.rb', line 37 def initialize(reporter, start, period) @reporter = reporter @start = start @period = period end |
Instance Attribute Details
#period ⇒ Object (readonly)
Returns the value of attribute period.
35 36 37 |
# File 'lib/leafy/core/scheduled_reporter.rb', line 35 def period @period end |
Instance Method Details
#call ⇒ Object
47 48 49 |
# File 'lib/leafy/core/scheduled_reporter.rb', line 47 def call @reporter.report end |
#delay ⇒ Object
43 44 45 |
# File 'lib/leafy/core/scheduled_reporter.rb', line 43 def delay @period - (Concurrent.monotonic_time - @start) % @period end |
#task(task = nil) ⇒ Object
51 52 53 |
# File 'lib/leafy/core/scheduled_reporter.rb', line 51 def task(task = nil) @task ||= task end |
#to_s ⇒ Object
55 56 57 |
# File 'lib/leafy/core/scheduled_reporter.rb', line 55 def to_s "start: #{Time.at(@start).utc} period: #{@period}" end |