Class: Nexpose::Schedule
- Inherits:
-
Object
- Object
- Nexpose::Schedule
- Defined in:
- lib/nexpose/common.rb
Overview
Configuration structure for schedules.
Defined Under Namespace
Modules: Type
Instance Attribute Summary collapse
-
#enabled ⇒ Object
Whether or not this schedule is enabled.
-
#incremental ⇒ Object
Returns the value of attribute incremental.
-
#interval ⇒ Object
The repeat interval based upon type.
-
#max_duration ⇒ Object
The amount of time, in minutes, to allow execution before stopping.
-
#not_valid_after ⇒ Object
The date after which the schedule is disabled, in ISO 8601 format.
-
#repeater_type ⇒ Object
Returns the value of attribute repeater_type.
-
#start ⇒ Object
The earliest date to generate the report on (in ISO 8601 format).
-
#type ⇒ Object
Valid schedule types: daily, hourly, monthly-date, monthly-day, weekly.
Class Method Summary collapse
Instance Method Summary collapse
- #as_xml ⇒ Object
-
#initialize(type, interval, start, enabled = true) ⇒ Schedule
constructor
A new instance of Schedule.
- #to_xml ⇒ Object
Constructor Details
#initialize(type, interval, start, enabled = true) ⇒ Schedule
Returns a new instance of Schedule.
113 114 115 116 117 118 |
# File 'lib/nexpose/common.rb', line 113 def initialize(type, interval, start, enabled = true) @type = type @interval = interval @start = start @enabled = enabled end |
Instance Attribute Details
#enabled ⇒ Object
Whether or not this schedule is enabled.
97 98 99 |
# File 'lib/nexpose/common.rb', line 97 def enabled @enabled end |
#incremental ⇒ Object
Returns the value of attribute incremental.
110 111 112 |
# File 'lib/nexpose/common.rb', line 110 def incremental @incremental end |
#interval ⇒ Object
The repeat interval based upon type.
101 102 103 |
# File 'lib/nexpose/common.rb', line 101 def interval @interval end |
#max_duration ⇒ Object
The amount of time, in minutes, to allow execution before stopping.
106 107 108 |
# File 'lib/nexpose/common.rb', line 106 def max_duration @max_duration end |
#not_valid_after ⇒ Object
The date after which the schedule is disabled, in ISO 8601 format.
108 109 110 |
# File 'lib/nexpose/common.rb', line 108 def not_valid_after @not_valid_after end |
#repeater_type ⇒ Object
Returns the value of attribute repeater_type.
111 112 113 |
# File 'lib/nexpose/common.rb', line 111 def repeater_type @repeater_type end |
#start ⇒ Object
The earliest date to generate the report on (in ISO 8601 format).
103 104 105 |
# File 'lib/nexpose/common.rb', line 103 def start @start end |
#type ⇒ Object
Valid schedule types: daily, hourly, monthly-date, monthly-day, weekly.
99 100 101 |
# File 'lib/nexpose/common.rb', line 99 def type @type end |
Class Method Details
.parse(xml) ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/nexpose/common.rb', line 137 def self.parse(xml) schedule = Schedule.new(xml.attributes['type'], xml.attributes['interval'].to_i, xml.attributes['start'], xml.attributes['enabled'] != '0') # Optional parameters. schedule.max_duration = xml.attributes['maxDuration'].to_i if xml.attributes['maxDuration'] schedule.not_valid_after = xml.attributes['notValidAfter'] if xml.attributes['notValidAfter'] schedule.incremental = (xml.attributes['incremental'] && xml.attributes['incremental'] == '1') schedule.repeater_type = xml.attributes['repeaterType'] if xml.attributes['repeaterType'] schedule end |
Instance Method Details
#as_xml ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/nexpose/common.rb', line 120 def as_xml xml = REXML::Element.new('Schedule') xml.attributes['enabled'] = @enabled ? 1 : 0 xml.attributes['type'] = @type xml.attributes['interval'] = @interval xml.attributes['start'] = @start xml.attributes['maxDuration'] = @max_duration if @max_duration xml.attributes['notValidAfter'] = @not_valid_after if @not_valid_after xml.attributes['incremental'] = @incremental ? 1 : 0 if @incremental xml.attributes['repeaterType'] = @repeater_type if @repeater_type xml end |
#to_xml ⇒ Object
133 134 135 |
# File 'lib/nexpose/common.rb', line 133 def to_xml as_xml.to_s end |