Class: ScanSchedule
- Inherits:
-
Object
- Object
- ScanSchedule
- Defined in:
- lib/domain/scan_schedule/model.rb,
lib/domain/scan_schedule/repeat.rb
Defined Under Namespace
Modules: OnRepeat Classes: Repeat
Instance Attribute Summary collapse
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#id ⇒ Object
Returns the value of attribute id.
-
#next_runtimes ⇒ Object
Returns the value of attribute next_runtimes.
-
#on_scan_repeat ⇒ Object
Returns the value of attribute on_scan_repeat.
-
#repeat ⇒ Object
Returns the value of attribute repeat.
-
#scan_engine_id ⇒ Object
Returns the value of attribute scan_engine_id.
-
#scan_name ⇒ Object
Returns the value of attribute scan_name.
-
#scan_template_id ⇒ Object
Returns the value of attribute scan_template_id.
-
#start ⇒ Object
Returns the value of attribute start.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id:, next_runtimes:, on_scan_repeat:, scan_engine_id:, start:, duration: nil, enabled: false, repeat: nil, scan_name: nil, scan_template_id: nil) ⇒ ScanSchedule
constructor
A new instance of ScanSchedule.
- #name ⇒ Object
-
#to_json(*_options) ⇒ Object
def self.slots(index) days = %w[monday tuesday friday saturday sunday] hours = [20, 21, 22, 23, 0] days % 25 hours % 5 end.
Constructor Details
#initialize(id:, next_runtimes:, on_scan_repeat:, scan_engine_id:, start:, duration: nil, enabled: false, repeat: nil, scan_name: nil, scan_template_id: nil) ⇒ ScanSchedule
Returns a new instance of ScanSchedule.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/domain/scan_schedule/model.rb', line 22 def initialize( id:, next_runtimes:, on_scan_repeat:, scan_engine_id:, start:, duration: nil, enabled: false, repeat: nil, scan_name: nil, scan_template_id: nil ) @id = id @duration = duration @enabled = enabled @next_runtimes = next_runtimes @on_scan_repeat = on_scan_repeat @repeat = repeat @scan_engine_id = scan_engine_id @scan_name = scan_name @scan_template_id = scan_template_id @start = start end |
Instance Attribute Details
#duration ⇒ Object
Returns the value of attribute duration.
11 12 13 |
# File 'lib/domain/scan_schedule/model.rb', line 11 def duration @duration end |
#enabled ⇒ Object
Returns the value of attribute enabled.
11 12 13 |
# File 'lib/domain/scan_schedule/model.rb', line 11 def enabled @enabled end |
#id ⇒ Object
Returns the value of attribute id.
11 12 13 |
# File 'lib/domain/scan_schedule/model.rb', line 11 def id @id end |
#next_runtimes ⇒ Object
Returns the value of attribute next_runtimes.
11 12 13 |
# File 'lib/domain/scan_schedule/model.rb', line 11 def next_runtimes @next_runtimes end |
#on_scan_repeat ⇒ Object
Returns the value of attribute on_scan_repeat.
11 12 13 |
# File 'lib/domain/scan_schedule/model.rb', line 11 def on_scan_repeat @on_scan_repeat end |
#repeat ⇒ Object
Returns the value of attribute repeat.
11 12 13 |
# File 'lib/domain/scan_schedule/model.rb', line 11 def repeat @repeat end |
#scan_engine_id ⇒ Object
Returns the value of attribute scan_engine_id.
11 12 13 |
# File 'lib/domain/scan_schedule/model.rb', line 11 def scan_engine_id @scan_engine_id end |
#scan_name ⇒ Object
Returns the value of attribute scan_name.
11 12 13 |
# File 'lib/domain/scan_schedule/model.rb', line 11 def scan_name @scan_name end |
#scan_template_id ⇒ Object
Returns the value of attribute scan_template_id.
11 12 13 |
# File 'lib/domain/scan_schedule/model.rb', line 11 def scan_template_id @scan_template_id end |
#start ⇒ Object
Returns the value of attribute start.
11 12 13 |
# File 'lib/domain/scan_schedule/model.rb', line 11 def start @start end |
Class Method Details
.from_json(data) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/domain/scan_schedule/model.rb', line 45 def self.from_json(data) ScanSchedule.new( id: data['id'], duration: data['duration'], enabled: data['enabled'], next_runtimes: data['nextRuntimes'], on_scan_repeat: data['onScanRepeat'], repeat: data['repeat'], scan_engine_id: data['scanEngineId'], scan_name: data['scanName'], scan_template_id: data['scanTemplateId'], start: data['start'] ) end |
Instance Method Details
#name ⇒ Object
82 83 84 |
# File 'lib/domain/scan_schedule/model.rb', line 82 def name scan_name end |
#to_json(*_options) ⇒ Object
def self.slots(index)
days = %w[monday tuesday friday saturday sunday]
hours = [20, 21, 22, 23, 0]
days % 25
hours % 5
end
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/domain/scan_schedule/model.rb', line 67 def to_json(*) { duration:, enabled:, id:, next_runtimes:, onScanRepeat: on_scan_repeat, repeat:, scanEngineId: scan_engine_id, scanName: scan_name, scanTemplateId: scan_template_id, start: }.to_json end |