class ActivePeriod::Holiday
Attributes
name[R]
@!attribute [r] name
@return [String] The name of the holiday
options[R]
@!attribute [r] options
@return [Array] The array of options for Holidays.on
regions[R]
@!attribute [r] regions
@return [<Symbol>] regions where the Holiday occure
Public Class Methods
_period()
click to toggle source
# File lib/active_period/holiday.rb, line 45 def self._period 'day' end
new(date: , name:, regions: , options: )
click to toggle source
@param date […] A valid param for Period.day(…) @param name [String] The name of the Holiday
@param regions [<Symbol>] region where the Holiday
occure @param options […] The array of options for Holidays.on @return [Type] ActivePeriod::Holiday
@raise RuntimeError if the gem “holidays” is not included
Calls superclass method
ActivePeriod::StandardPeriod::new
# File lib/active_period/holiday.rb, line 23 def initialize(date: , name:, regions: , options: ) raise I18n.t(:gem_require, scope: %i[active_period holiday_period]) unless Object.const_defined?('Holidays') super(date) @name = name @regions = regions @options = options end
Public Instance Methods
+(duration)
click to toggle source
Shift a period to the past acording to her ending point @return [self] A new period of the same kind
# File lib/active_period/holiday.rb, line 57 def +(duration) raise NotImplementedError end
-(duration)
click to toggle source
Shift a period to the past acording to her starting point @return [self] A new period of the same kind
# File lib/active_period/holiday.rb, line 51 def -(duration) raise NotImplementedError end
_period()
click to toggle source
# File lib/active_period/holiday.rb, line 41 def _period self.class._period end
i18n() { |self| ... }
click to toggle source
# File lib/active_period/holiday.rb, line 69 def i18n(&block) return yield(self) if block.present? I18n.t(:default_format, scope: i18n_scope, name: name, wday: I18n.l(from, format: '%A').capitalize, day: from.day, month: I18n.l(from, format: '%B').capitalize, year: from.year) end
Also aliased as: inspect
i18n_scope()
click to toggle source
# File lib/active_period/holiday.rb, line 82 def i18n_scope [:active_period, :holiday_period] end
next()
click to toggle source
# File lib/active_period/holiday.rb, line 32 def next Period.new(beginning+1.day..).holidays(options).first end
Also aliased as: succ
prev()
click to toggle source
# File lib/active_period/holiday.rb, line 37 def prev Period.new(...ending).holidays(options).last end
strftime(format)
click to toggle source
# File lib/active_period/holiday.rb, line 61 def strftime(format) from.strftime(format) end
to_s(format: '%d/%m/%Y')
click to toggle source
# File lib/active_period/holiday.rb, line 65 def to_s(format: '%d/%m/%Y') strftime(format) end