Class: ScanSchedule

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#durationObject

Returns the value of attribute duration.



11
12
13
# File 'lib/domain/scan_schedule/model.rb', line 11

def duration
  @duration
end

#enabledObject

Returns the value of attribute enabled.



11
12
13
# File 'lib/domain/scan_schedule/model.rb', line 11

def enabled
  @enabled
end

#idObject

Returns the value of attribute id.



11
12
13
# File 'lib/domain/scan_schedule/model.rb', line 11

def id
  @id
end

#next_runtimesObject

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_repeatObject

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

#repeatObject

Returns the value of attribute repeat.



11
12
13
# File 'lib/domain/scan_schedule/model.rb', line 11

def repeat
  @repeat
end

#scan_engine_idObject

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_nameObject

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_idObject

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

#startObject

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

#nameObject



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(*_options)
  {
    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