Class: Thunderbird::Subdirectory
- Inherits:
-
Object
- Object
- Thunderbird::Subdirectory
- Defined in:
- lib/thunderbird/subdirectory.rb
Overview
Represents a subdirectory containing folders
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
‘path` is the UI path, it doesn’t have the ‘.sbd’ extensions that are present in the real, file system path.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
-
#full_path ⇒ Object
subdirectory relative path is ‘Foo.sbd/Bar.sbd/Baz.sbd’.
-
#initialize(root:, path:) ⇒ Subdirectory
constructor
A new instance of Subdirectory.
- #set_up ⇒ Object
Constructor Details
#initialize(root:, path:) ⇒ Subdirectory
Returns a new instance of Subdirectory.
13 14 15 16 |
# File 'lib/thunderbird/subdirectory.rb', line 13 def initialize(root:, path:) @root = root @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
‘path` is the UI path, it doesn’t have the ‘.sbd’ extensions that are present in the real, file system path
10 11 12 |
# File 'lib/thunderbird/subdirectory.rb', line 10 def path @path end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
11 12 13 |
# File 'lib/thunderbird/subdirectory.rb', line 11 def root @root end |
Instance Method Details
#full_path ⇒ Object
subdirectory relative path is ‘Foo.sbd/Bar.sbd/Baz.sbd’
36 37 38 39 |
# File 'lib/thunderbird/subdirectory.rb', line 36 def full_path relative_path = File.join(subdirectories) File.join(root, relative_path) end |
#set_up ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/thunderbird/subdirectory.rb', line 18 def set_up raise "Cannot create a subdirectory without a path" if !sub_directory? if sub_sub_directory? parent_ok = parent.set_up return false if !parent_ok end ok = check return false if !ok FileUtils.mkdir_p full_path placeholder.touch true end |