Sha256: 799f84784123916b018a4a5a55ccb5c4bec89a0c5b4db9185a4d990fef7823f0

Contents?: true

Size: 1 KB

Versions: 11

Compression:

Stored size: 1 KB

Contents

require "thunderbird/profile"
require "thunderbird/subdirectory"

# A local folder is a file containing emails
class Thunderbird::LocalFolder
  attr_reader :path
  attr_reader :profile

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

  def set_up
    return if path_elements.empty?

    return true if !in_subdirectory?

    subdirectory.set_up
  end

  def full_path
    if in_subdirectory?
      File.join(subdirectory.full_path, folder_name)
    else
      folder_name
    end
  end

  def exists?
    File.exist?(full_path)
  end

  def msf_path
    "#{path}.msf"
  end

  def msf_exists?
    File.exist?(msf_path)
  end

  private

  def in_subdirectory?
    path_elements.count > 1
  end

  def subdirectory
    return nil if !in_subdirectory?

    Thunderbird::Subdirectory.new(profile, subdirectory_path)
  end

  def path_elements
    path.split(File::SEPARATOR)
  end

  def subdirectory_path
    File.join(path_elements[0..-2])
  end

  def folder_name
    path_elements[-1]
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
imap-backup-5.0.0 lib/thunderbird/local_folder.rb
imap-backup-4.2.2 lib/thunderbird/local_folder.rb
imap-backup-4.2.1 lib/thunderbird/local_folder.rb
imap-backup-4.2.0 lib/thunderbird/local_folder.rb
imap-backup-4.1.2 lib/thunderbird/local_folder.rb
imap-backup-4.1.1 lib/thunderbird/local_folder.rb
imap-backup-4.0.7 lib/thunderbird/local_folder.rb
imap-backup-4.0.6 lib/thunderbird/local_folder.rb
imap-backup-4.0.5 lib/thunderbird/local_folder.rb
imap-backup-4.0.4 lib/thunderbird/local_folder.rb
imap-backup-4.0.3 lib/thunderbird/local_folder.rb