Class: GovukError::GovukDataSync

Inherits:
Object
  • Object
show all
Defined in:
lib/govuk_app_config/govuk_error/govuk_data_sync.rb

Defined Under Namespace

Classes: MalformedDataSyncPeriod

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#fromObject (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

#toObject (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

Returns:

  • (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