Class: Linux::Lxc::Directory
- Inherits:
-
Object
- Object
- Linux::Lxc::Directory
- Defined in:
- lib/linux/lxc/directory.rb
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Instance Method Summary collapse
- #add_file(fname) ⇒ Object
- #all_lines(&block) ⇒ Object
- #get(key) ⇒ Object
-
#initialize(fname, index) ⇒ Directory
constructor
A new instance of Directory.
- #to_s ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(fname, index) ⇒ Directory
Returns a new instance of Directory.
21 22 23 24 25 |
# File 'lib/linux/lxc/directory.rb', line 21 def initialize(fname, index) @file = fname @index = index @entries = {} end |
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
20 21 22 |
# File 'lib/linux/lxc/directory.rb', line 20 def entries @entries end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
20 21 22 |
# File 'lib/linux/lxc/directory.rb', line 20 def file @file end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
20 21 22 |
# File 'lib/linux/lxc/directory.rb', line 20 def index @index end |
Instance Method Details
#add_file(fname) ⇒ Object
41 42 43 |
# File 'lib/linux/lxc/directory.rb', line 41 def add_file(fname) @entries[fname] ||= @index.add_file(fname, self) end |
#all_lines(&block) ⇒ Object
27 28 29 30 31 |
# File 'lib/linux/lxc/directory.rb', line 27 def all_lines(&block) @entries.values.each do |entry| entry.all_lines(&block) end end |
#get(key) ⇒ Object
37 38 39 |
# File 'lib/linux/lxc/directory.rb', line 37 def get(key) @index.get_key(key) end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/linux/lxc/directory.rb', line 33 def to_s @file end |
#write ⇒ Object
45 46 47 48 49 50 |
# File 'lib/linux/lxc/directory.rb', line 45 def write FileUtils.mkdir_p file @entries.values.each do |entry| entry.write end end |