Class: OsCtld::CGroup::Param

Inherits:
Struct
  • Object
show all
Defined in:
lib/osctld/cgroup/param.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



3
4
5
# File 'lib/osctld/cgroup/param.rb', line 3

def name
  @name
end

#persistentObject

Returns the value of attribute persistent

Returns:

  • (Object)

    the current value of persistent



3
4
5
# File 'lib/osctld/cgroup/param.rb', line 3

def persistent
  @persistent
end

#subsystemObject

Returns the value of attribute subsystem

Returns:

  • (Object)

    the current value of subsystem



3
4
5
# File 'lib/osctld/cgroup/param.rb', line 3

def subsystem
  @subsystem
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



3
4
5
# File 'lib/osctld/cgroup/param.rb', line 3

def value
  @value
end

#versionObject

Returns the value of attribute version

Returns:

  • (Object)

    the current value of version



3
4
5
# File 'lib/osctld/cgroup/param.rb', line 3

def version
  @version
end

Class Method Details

.import(hash) ⇒ Object

Load from client



16
17
18
19
20
21
22
23
24
# File 'lib/osctld/cgroup/param.rb', line 16

def self.import(hash)
  new(
    hash.fetch(:version, CGroup.version),
    hash[:subsystem],
    hash[:parameter],
    hash[:value],
    hash.has_key?(:persistent) ? hash[:persistent] : true
  )
end

.load(hash) ⇒ Object

Load from config



5
6
7
8
9
10
11
12
13
# File 'lib/osctld/cgroup/param.rb', line 5

def self.load(hash)
  new(
    hash.fetch('version', 1),
    hash['subsystem'],
    hash['name'],
    hash['value'],
    true
  )
end

Instance Method Details

#dumpObject

Dump to config



27
28
29
# File 'lib/osctld/cgroup/param.rb', line 27

def dump
  to_h.transform_keys(&:to_s)
end

#exportObject

Export to client



32
33
34
35
36
37
38
39
40
# File 'lib/osctld/cgroup/param.rb', line 32

def export
  {
    version:,
    subsystem:,
    parameter: name,
    value:,
    persistent: persistent ? true : false
  }
end