Class: Linux::Lxc::Index
- Inherits:
-
Object
- Object
- Linux::Lxc::Index
- Defined in:
- lib/linux/lxc/index.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
- #add_file(fname, dir) ⇒ Object
- #add_line(key, line) ⇒ Object
- #delete_key(key) ⇒ Object
- #get_directory(fname) ⇒ Object
- #get_key(key) ⇒ Object
-
#initialize ⇒ Index
constructor
A new instance of Index.
Constructor Details
#initialize ⇒ Index
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
#files ⇒ Object (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 |