class AIPP::AIRAC
AIRAC
cycle date calculations
@example
airac = AIPP::AIRAC.new('2018-01-01') airac.date # => #<Date: 2017-12-07 ((2458095j,0s,0n),+0s,2299161j)> airac.id # => 1713 airac.next_date # => #<Date: 2018-01-04 ((2458123j,0s,0n),+0s,2299161j)> airac.next_id # => 1801
Constants
Attributes
date[R]
@return [Date] AIRAC
effective on date
id[R]
@return [Integer] AIRAC
cycle ID
Public Class Methods
new(any_date = nil)
click to toggle source
@param any_date [Date] any date within the AIRAC
cycle (default: today)
# File lib/aipp/airac.rb 25 def initialize(any_date = nil) 26 any_date = any_date ? Date.parse(any_date.to_s) : Date.today 27 fail(ArgumentError, "cannot calculate dates before #{ROOT_DATE}") if any_date < ROOT_DATE 28 @date = date_for(any_date) 29 @id = id_for(@date) 30 end
Public Instance Methods
next_date()
click to toggle source
@return [Date] next AIRAC
effective on date
# File lib/aipp/airac.rb 33 def next_date 34 date + DAYS_PER_CYCLE 35 end
next_id()
click to toggle source
@return [Integer] next AIRAC
cycle ID
# File lib/aipp/airac.rb 38 def next_id 39 id_for next_date 40 end
Private Instance Methods
date_for(any_date)
click to toggle source
Find the AIRAC
date for any_date
# File lib/aipp/airac.rb 45 def date_for(any_date) 46 ROOT_DATE + (any_date - ROOT_DATE).to_i / DAYS_PER_CYCLE * DAYS_PER_CYCLE 47 end