Class: Karafka::Pro::ScheduledMessages::Day
- Inherits:
-
Object
- Object
- Karafka::Pro::ScheduledMessages::Day
- Defined in:
- lib/karafka/pro/scheduled_messages/day.rb
Overview
Just a simple UTC day implementation. Since we operate on a scope of one day, this allows us to encapsulate when given day ends
Instance Attribute Summary collapse
-
#created_at ⇒ Integer
readonly
Utc timestamp when this day object was created.
-
#ends_at ⇒ Integer
readonly
Equal to 23:59:59.
-
#starts_at ⇒ Integer
readonly
Utc timestamp when this day starts.
Instance Method Summary collapse
-
#ended? ⇒ Boolean
Did the current day we operate on ended.
-
#initialize ⇒ Day
constructor
A new instance of Day.
Constructor Details
#initialize ⇒ Day
Returns a new instance of Day.
21 22 23 24 25 26 27 28 |
# File 'lib/karafka/pro/scheduled_messages/day.rb', line 21 def initialize @created_at = Time.now.to_i time = Time.at(@created_at).utc @starts_at = Time.utc(time.year, time.month, time.day).to_i @ends_at = @starts_at + 86_399 end |
Instance Attribute Details
#created_at ⇒ Integer (readonly)
Returns utc timestamp when this day object was created. Keep in mind, that this is not when the day started but when this object was created.
14 15 16 |
# File 'lib/karafka/pro/scheduled_messages/day.rb', line 14 def created_at @created_at end |
#ends_at ⇒ Integer (readonly)
Equal to 23:59:59.
17 18 19 |
# File 'lib/karafka/pro/scheduled_messages/day.rb', line 17 def ends_at @ends_at end |
#starts_at ⇒ Integer (readonly)
Returns utc timestamp when this day starts. Equal to 00:00:00.
19 20 21 |
# File 'lib/karafka/pro/scheduled_messages/day.rb', line 19 def starts_at @starts_at end |
Instance Method Details
#ended? ⇒ Boolean
Returns did the current day we operate on ended.
31 32 33 |
# File 'lib/karafka/pro/scheduled_messages/day.rb', line 31 def ended? @ends_at < Time.now.to_i end |