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
-
#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.
117 118 119 120 121 122 |
# File 'lib/nexpose/common.rb', line 117 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.
101 102 103 |
# File 'lib/nexpose/common.rb', line 101 def enabled @enabled end |
#incremental ⇒ Object
Returns the value of attribute incremental.
114 115 116 |
# File 'lib/nexpose/common.rb', line 114 def incremental @incremental end |
#interval ⇒ Object
The repeat interval based upon type.
105 106 107 |
# File 'lib/nexpose/common.rb', line 105 def interval @interval end |
#max_duration ⇒ Object
The amount of time, in minutes, to allow execution before stopping.
110 111 112 |
# File 'lib/nexpose/common.rb', line 110 def max_duration @max_duration end |
#not_valid_after ⇒ Object
The date after which the schedule is disabled, in ISO 8601 format.
112 113 114 |
# File 'lib/nexpose/common.rb', line 112 def not_valid_after @not_valid_after end |
#repeater_type ⇒ Object
Returns the value of attribute repeater_type.
115 116 117 |
# File 'lib/nexpose/common.rb', line 115 def repeater_type @repeater_type end |
#start ⇒ Object
The earliest date to generate the report on (in ISO 8601 format).
107 108 109 |
# File 'lib/nexpose/common.rb', line 107 def start @start end |
#type ⇒ Object
Valid schedule types: daily, hourly, monthly-date, monthly-day, weekly.
103 104 105 |
# File 'lib/nexpose/common.rb', line 103 def type @type end |
Class Method Details
.parse(xml) ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/nexpose/common.rb', line 133 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
#to_xml ⇒ Object
124 125 126 127 128 129 130 131 |
# File 'lib/nexpose/common.rb', line 124 def to_xml xml = %(<Schedule enabled='#{@enabled ? 1 : 0}' type='#{@type}' interval='#{@interval}' start='#{@start}') xml << %( maxDuration='#{@max_duration}') if @max_duration xml << %( notValidAfter='#{@not_valid_after}') if @not_valid_after xml << %( incremental='#{@incremental ? 1 : 0}') if @incremental xml << %( repeaterType='#{@repeater_type}') if @repeater_type xml << '/>' end |