Class: Nexpose::Schedule
- Inherits:
-
Object
- Object
- Nexpose::Schedule
- Defined in:
- lib/nexpose/common.rb
Overview
Configuration structure for schedules.
Instance Attribute Summary collapse
-
#enabled ⇒ Object
Whether or not this schedule is enabled.
-
#incremental ⇒ Object
– TODO These are not captured or put to XML.
-
#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.
119 120 121 122 123 124 |
# File 'lib/nexpose/common.rb', line 119 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.
100 101 102 |
# File 'lib/nexpose/common.rb', line 100 def enabled @enabled end |
#incremental ⇒ Object
– TODO These are not captured or put to XML. ++
116 117 118 |
# File 'lib/nexpose/common.rb', line 116 def incremental @incremental end |
#interval ⇒ Object
The repeat interval based upon type.
104 105 106 |
# File 'lib/nexpose/common.rb', line 104 def interval @interval end |
#max_duration ⇒ Object
The amount of time, in minutes, to allow execution before stopping.
109 110 111 |
# File 'lib/nexpose/common.rb', line 109 def max_duration @max_duration end |
#not_valid_after ⇒ Object
The date after which the schedule is disabled, in ISO 8601 format.
111 112 113 |
# File 'lib/nexpose/common.rb', line 111 def not_valid_after @not_valid_after end |
#repeater_type ⇒ Object
Returns the value of attribute repeater_type.
117 118 119 |
# File 'lib/nexpose/common.rb', line 117 def repeater_type @repeater_type end |
#start ⇒ Object
The earliest date to generate the report on (in ISO 8601 format).
106 107 108 |
# File 'lib/nexpose/common.rb', line 106 def start @start end |
#type ⇒ Object
Valid schedule types: daily, hourly, monthly-date, monthly-day, weekly.
102 103 104 |
# File 'lib/nexpose/common.rb', line 102 def type @type end |
Class Method Details
.parse(xml) ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/nexpose/common.rb', line 133 def self.parse(xml) xml.elements.each('//Schedule') do |sched| schedule = Schedule.new(sched.attributes['type'], sched.attributes['interval'].to_i, sched.attributes['start'], sched.attributes['enabled'] || true) # Optional parameters. schedule.max_duration = sched.attributes['maxDuration'].to_i if sched.attributes['maxDuration'] schedule.not_valid_after = sched.attributes['notValidAfter'] if sched.attributes['notValidAfter'] return schedule end end |
Instance Method Details
#to_xml ⇒ Object
126 127 128 129 130 131 |
# File 'lib/nexpose/common.rb', line 126 def to_xml xml = %Q{<Schedule enabled='#{@enabled ? 1 : 0}' type='#{@type}' interval='#{@interval}' start='#{@start}'} xml << %Q{ maxDuration='#@max_duration'} if @max_duration xml << %Q{ notValidAfter='#@not_valid_after'} if @not_valid_after xml << '/>' end |