Class: OsCtld::AutoStart::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/osctld/auto_start/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ct, priority, delay) ⇒ Config

Returns a new instance of Config.



9
10
11
12
13
# File 'lib/osctld/auto_start/config.rb', line 9

def initialize(ct, priority, delay)
  @ct = ct
  @priority = priority
  @delay = delay
end

Instance Attribute Details

#ctObject (readonly)

Returns the value of attribute ct.



7
8
9
# File 'lib/osctld/auto_start/config.rb', line 7

def ct
  @ct
end

#delayObject (readonly)

Returns the value of attribute delay.



7
8
9
# File 'lib/osctld/auto_start/config.rb', line 7

def delay
  @delay
end

#priorityObject (readonly)

Returns the value of attribute priority.



7
8
9
# File 'lib/osctld/auto_start/config.rb', line 7

def priority
  @priority
end

Class Method Details

.load(ct, cfg) ⇒ Object



3
4
5
# File 'lib/osctld/auto_start/config.rb', line 3

def self.load(ct, cfg)
  new(ct, cfg['priority'], cfg['delay'])
end

Instance Method Details

#<=>(other) ⇒ Object

Sort by priority and container id



16
17
18
# File 'lib/osctld/auto_start/config.rb', line 16

def <=>(other)
  [priority, ct.id] <=> [other.priority, other.ct.id]
end

#dumpObject



20
21
22
23
24
25
# File 'lib/osctld/auto_start/config.rb', line 20

def dump
  {
    'priority' => priority,
    'delay' => delay
  }
end

#dup(new_ct) ⇒ Object



27
28
29
30
31
# File 'lib/osctld/auto_start/config.rb', line 27

def dup(new_ct)
  ret = super()
  ret.instance_variable_set('@ct', new_ct)
  ret
end