Class: ExistClient::ReportPeriod

Inherits:
Object
  • Object
show all
Includes:
LogicalDate
Defined in:
lib/exist_client/report_period.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from LogicalDate

#logical_date

Constructor Details

#initialize(last_report_date) ⇒ ReportPeriod

Returns a new instance of ReportPeriod.



7
8
9
10
11
12
13
# File 'lib/exist_client/report_period.rb', line 7

def initialize(last_report_date)
  date = last_report_date + 1
  end_date = logical_date(Time.now)

  @start_time = Time.new(date.year, date.month, date.day, Config.cutoff_hour)
  @end_time = Time.new(end_date.year, end_date.month, end_date.day, Config.cutoff_hour) - 1
end

Instance Attribute Details

#end_timeObject (readonly)

Returns the value of attribute end_time.



5
6
7
# File 'lib/exist_client/report_period.rb', line 5

def end_time
  @end_time
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



5
6
7
# File 'lib/exist_client/report_period.rb', line 5

def start_time
  @start_time
end

Instance Method Details

#include?(time) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/exist_client/report_period.rb', line 19

def include?(time)
  time.between?(start_time, end_time)
end

#valid?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/exist_client/report_period.rb', line 15

def valid?
  start_time < end_time
end