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.
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
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
6 7 8 |
# File 'lib/linux/lxc/directory.rb', line 6 def entries @entries end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
6 7 8 |
# File 'lib/linux/lxc/directory.rb', line 6 def file @file end |
#index ⇒ Object (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_s ⇒ Object
19 20 21 |
# File 'lib/linux/lxc/directory.rb', line 19 def to_s @file end |
#write ⇒ Object
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 |