Class: Linux::Lxc::Index

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeIndex

Returns a new instance of Index.



6
7
8
9
10
# File 'lib/linux/lxc/index.rb', line 6

def initialize
  @key_index = {}
  @dirs = {}
  @files = {}
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



4
5
6
# File 'lib/linux/lxc/index.rb', line 4

def files
  @files
end

Instance Method Details

#add_file(fname, dir) ⇒ Object



30
31
32
# File 'lib/linux/lxc/index.rb', line 30

def add_file(fname, dir)
  @files[fname] ||= File.new(fname, dir, self)
end

#add_line(key, line) ⇒ Object



12
13
14
15
# File 'lib/linux/lxc/index.rb', line 12

def add_line(key, line)
  @key_index[key] ||= Lines.new
  @key_index[key].add(line)
end

#delete_key(key) ⇒ Object



21
22
23
24
# File 'lib/linux/lxc/index.rb', line 21

def delete_key(key)
  return if @key_index[key].nil? || !@key_index[key].empty?
  @key_index.delete(key)
end

#get_directory(fname) ⇒ Object



26
27
28
# File 'lib/linux/lxc/index.rb', line 26

def get_directory(fname)
  @dirs[fname] ||= Directory.new(fname, self)
end

#get_key(key) ⇒ Object



17
18
19
# File 'lib/linux/lxc/index.rb', line 17

def get_key(key)
  @key_index[key]
end