Class: LibTAD::DateCalculator::Period

Inherits:
Object
  • Object
show all
Defined in:
lib/types/date_calculator/period.rb

Overview

Calculated results for a requested period.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Period

Returns a new instance of Period.



33
34
35
36
37
38
39
40
41
# File 'lib/types/date_calculator/period.rb', line 33

def initialize(hash)
  @includeddays = hash.fetch('includeddays', nil)
  @calendardays = hash.fetch('calendardays', nil)
  @skippeddays = hash.fetch('skippeddays', nil)
  @startdate = ::LibTAD::TADTime::TADTime.new hash['startdate'] unless !hash.key?('startdate')
  @enddate = ::LibTAD::TADTime::TADTime.new hash['enddate'] unless !hash.key?('enddate')
  @weekdays = ::LibTAD::DateCalculator::Weekdays.new hash['weekdays'] unless !hash.key?('weekdays')
  @holidays = ::LibTAD::DateCalculator::BusinessHoliday.new hash['holidays'] unless !hash.key?('holidays')
end

Instance Attribute Details

#calendardaysInteger (readonly)

Number of calendar days in calculated period.

Returns:

  • (Integer)


11
12
13
# File 'lib/types/date_calculator/period.rb', line 11

def calendardays
  @calendardays
end

#enddate::LibTAD::TADTime::TADTime (readonly)

The date the calculation ended on.



23
24
25
# File 'lib/types/date_calculator/period.rb', line 23

def enddate
  @enddate
end

#holidays::LibTAD::DateCalculator::BusinessHoliday (readonly)

Holidays which occur in the requested period.



31
32
33
# File 'lib/types/date_calculator/period.rb', line 31

def holidays
  @holidays
end

#includeddaysInteger (readonly)

Number of days calculated.

Returns:

  • (Integer)


7
8
9
# File 'lib/types/date_calculator/period.rb', line 7

def includeddays
  @includeddays
end

#skippeddaysInteger (readonly)

Number of days which was skipped in the calculated period.

Returns:

  • (Integer)


15
16
17
# File 'lib/types/date_calculator/period.rb', line 15

def skippeddays
  @skippeddays
end

#startdate::LibTAD::TADTime::TADTime (readonly)

The date the calculation started from.



19
20
21
# File 'lib/types/date_calculator/period.rb', line 19

def startdate
  @startdate
end

#weekdays::LibTAD::DateCalculator::Weekdays (readonly)

The spread of excluded or included weekdays in includeddays.



27
28
29
# File 'lib/types/date_calculator/period.rb', line 27

def weekdays
  @weekdays
end