Class: PuppetX::PuppetLabs::ScheduledTask::Trigger::V2::WeeksOfMonth Private
- Inherits:
-
Object
- Object
- PuppetX::PuppetLabs::ScheduledTask::Trigger::V2::WeeksOfMonth
- Defined in:
- lib/puppet_x/puppetlabs/scheduled_task/trigger.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Gets or sets the weeks of the month during which the task runs.
Constant Summary collapse
- FIRST =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
msdn.microsoft.com/en-us/library/windows/desktop/aa380733(v=vs.85).aspx First week of the month to HEX
0x01
- SECOND =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Second week of the month to HEX
0x02
- THIRD =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Third week of the month to HEX
0x04
- FOURTH =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Forth week of the month to HEX
0x08
- LAST =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Last week of the month to HEX
0x10
- MAX_VALUE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
5 bits for 5 possible weeks to set
0b11111
- WEEK_OF_MONTH_CONST_MAP =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Week of the month to HEX map
{ 'first' => FIRST, 'second' => SECOND, 'third' => THIRD, 'fourth' => FOURTH, 'last' => LAST, }.freeze
Class Method Summary collapse
-
.bitmask_to_names(bitmask) ⇒ Object
private
Converts bitmask to names.
-
.names_to_bitmask(week_names) ⇒ Object
private
Converts names to bitmask.
Class Method Details
.bitmask_to_names(bitmask) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts bitmask to names
592 593 594 595 596 597 598 599 600 601 |
# File 'lib/puppet_x/puppetlabs/scheduled_task/trigger.rb', line 592 def self.bitmask_to_names(bitmask) bitmask = Integer(bitmask) if bitmask.negative? || bitmask > MAX_VALUE raise ArgumentError, "bitmask must be specified as an integer from 0 to #{MAX_VALUE.to_s(10)}" end WEEK_OF_MONTH_CONST_MAP.values.each_with_object([]) do |week, names| names << WEEK_OF_MONTH_CONST_MAP.key(week) if bitmask & week != 0 end end |
.names_to_bitmask(week_names) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts names to bitmask
583 584 585 586 587 588 589 |
# File 'lib/puppet_x/puppetlabs/scheduled_task/trigger.rb', line 583 def self.names_to_bitmask(week_names) week_names = [week_names].flatten invalid_weeks = week_names - WEEK_OF_MONTH_CONST_MAP.keys raise ArgumentError, "week_names value #{invalid_weeks.join(', ')} is invalid. Expected first, second, third, fourth or last." unless invalid_weeks.empty? week_names.reduce(0) { |bitmask, day| bitmask | WEEK_OF_MONTH_CONST_MAP[day] } end |