Class: Haconiwa::CGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/haconiwa/cgroup.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCGroup

Returns a new instance of CGroup.



5
6
7
# File 'lib/haconiwa/cgroup.rb', line 5

def initialize
  @groups = {}
end

Instance Attribute Details

#groupsObject (readonly)

Returns the value of attribute groups.



8
9
10
# File 'lib/haconiwa/cgroup.rb', line 8

def groups
  @groups
end

Instance Method Details

#[](key) ⇒ Object



10
11
12
# File 'lib/haconiwa/cgroup.rb', line 10

def [](key)
  @groups[key]
end

#[]=(key, value) ⇒ Object



14
15
16
# File 'lib/haconiwa/cgroup.rb', line 14

def []=(key, value)
  @groups[key] = value
end

#register_all!(to: nil) ⇒ Object



22
23
24
25
26
27
# File 'lib/haconiwa/cgroup.rb', line 22

def register_all!(to: nil)
  cg = SmallCgroup.new(name: to)
  groups.each do |k, v|
    cg.register k, v
  end
end

#to_dirsObject



18
19
20
# File 'lib/haconiwa/cgroup.rb', line 18

def to_dirs
  groups.keys.map{|k| k.split('.').first }.uniq
end