Class: GovukError::GovukDataSync
- Inherits:
-
Object
- Object
- GovukError::GovukDataSync
- Defined in:
- lib/govuk_app_config/govuk_error/govuk_data_sync.rb
Defined Under Namespace
Classes: MalformedDataSyncPeriod
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
- #in_progress? ⇒ Boolean
-
#initialize(govuk_data_sync_period) ⇒ GovukDataSync
constructor
A new instance of GovukDataSync.
Constructor Details
#initialize(govuk_data_sync_period) ⇒ GovukDataSync
Returns a new instance of GovukDataSync.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/govuk_app_config/govuk_error/govuk_data_sync.rb', line 13 def initialize(govuk_data_sync_period) return if govuk_data_sync_period.nil? parts = govuk_data_sync_period.split("-") raise MalformedDataSyncPeriod, govuk_data_sync_period unless parts.count == 2 @from, @to = parts.map { |time| Time.parse(time) } rescue ArgumentError raise MalformedDataSyncPeriod, govuk_data_sync_period end |
Instance Attribute Details
#from ⇒ Object (readonly)
Returns the value of attribute from.
11 12 13 |
# File 'lib/govuk_app_config/govuk_error/govuk_data_sync.rb', line 11 def from @from end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
11 12 13 |
# File 'lib/govuk_app_config/govuk_error/govuk_data_sync.rb', line 11 def to @to end |
Instance Method Details
#in_progress? ⇒ Boolean
24 25 26 |
# File 'lib/govuk_app_config/govuk_error/govuk_data_sync.rb', line 24 def in_progress? !from.nil? && !to.nil? && in_time_range?(from, to) end |