Class: Imap::Backup::FileMode

Inherits:
Object
  • Object
show all
Defined in:
lib/imap/backup/file_mode.rb

Overview

Accesses a file’s access permissions

Instance Method Summary collapse

Constructor Details

#initialize(filename:) ⇒ FileMode

Returns a new instance of FileMode.



6
7
8
# File 'lib/imap/backup/file_mode.rb', line 6

def initialize(filename:)
  @filename = filename
end

Instance Method Details

#modeInteger?

Returns The user, group and “other” part of the file’s “mode”.

Returns:

  • (Integer, nil)

    The user, group and “other” part of the file’s “mode”



11
12
13
14
15
16
# File 'lib/imap/backup/file_mode.rb', line 11

def mode
  return nil if !File.exist?(filename)

  stat = File.stat(filename)
  stat.mode & 0o777
end