Class: Linux::Lxc::Directory

Inherits:
Object
  • Object
show all
Defined in:
lib/linux/lxc/directory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fname, index) ⇒ Directory

Returns a new instance of Directory.



7
8
9
10
11
# File 'lib/linux/lxc/directory.rb', line 7

def initialize(fname, index)
  @file = fname
  @index = index
  @entries = {}
end

Instance Attribute Details

#entriesObject (readonly)

Returns the value of attribute entries.



6
7
8
# File 'lib/linux/lxc/directory.rb', line 6

def entries
  @entries
end

#fileObject (readonly)

Returns the value of attribute file.



6
7
8
# File 'lib/linux/lxc/directory.rb', line 6

def file
  @file
end

#indexObject (readonly)

Returns the value of attribute index.



6
7
8
# File 'lib/linux/lxc/directory.rb', line 6

def index
  @index
end

Instance Method Details

#add_file(fname) ⇒ Object



27
28
29
# File 'lib/linux/lxc/directory.rb', line 27

def add_file(fname)
  @entries[fname] ||= @index.add_file(fname, self)
end

#all_lines(&block) ⇒ Object



13
14
15
16
17
# File 'lib/linux/lxc/directory.rb', line 13

def all_lines(&block)
  @entries.values.each do |entry|
    entry.all_lines(&block)
  end
end

#get(key) ⇒ Object



23
24
25
# File 'lib/linux/lxc/directory.rb', line 23

def get(key)
  @index.get_key(key)
end

#to_sObject



19
20
21
# File 'lib/linux/lxc/directory.rb', line 19

def to_s
  @file
end

#writeObject



31
32
33
34
35
36
# File 'lib/linux/lxc/directory.rb', line 31

def write
  FileUtils.mkdir_p file
  @entries.values.each do |entry|
    entry.write
  end
end