Class: Thunderbird::Subdirectory

Inherits:
Object
  • Object
show all
Defined in:
lib/thunderbird/subdirectory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(profile, path) ⇒ Subdirectory

Returns a new instance of Subdirectory.



9
10
11
12
# File 'lib/thunderbird/subdirectory.rb', line 9

def initialize(profile, path)
  @profile = profile
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

‘path` is the UI path, it doesn’t have the ‘.sbd’ extensions that are present in the real, file system path



6
7
8
# File 'lib/thunderbird/subdirectory.rb', line 6

def path
  @path
end

#profileObject (readonly)

Returns the value of attribute profile.



7
8
9
# File 'lib/thunderbird/subdirectory.rb', line 7

def profile
  @profile
end

Instance Method Details

#full_pathObject

subdirectory relative path is ‘Foo.sbd/Bar.sbd/Baz.sbd’



32
33
34
35
# File 'lib/thunderbird/subdirectory.rb', line 32

def full_path
  relative_path = File.join(subdirectories)
  File.join(profile.local_folders_path, relative_path)
end

#set_upObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/thunderbird/subdirectory.rb', line 14

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