Class: Ftpd::ListFormat::Ls::FileMode

Inherits:
Object
  • Object
show all
Defined in:
lib/ftpd/list_format/ls.rb

Overview

Map file mode bits into ls style file mode letters

Instance Method Summary collapse

Constructor Details

#initialize(mode) ⇒ FileMode

Returns a new instance of FileMode.

Parameters:

  • mode (Integer)

    File mode bits, as returned by File::Stat#mode



98
99
100
# File 'lib/ftpd/list_format/ls.rb', line 98

def initialize(mode)
  @mode = mode
end

Instance Method Details

#lettersObject

Return the mode bits as ls style letters. For example, “-rw-r–r–”



105
106
107
108
109
110
111
# File 'lib/ftpd/list_format/ls.rb', line 105

def letters
  [
    triad(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE, SET_UID, 'Ss'),
    triad(GROUP_READ, GROUP_WRITE, GROUP_EXECUTE, SET_GID, 'Ss'),
    triad(OTHER_READ, OTHER_WRITE, OTHER_EXECUTE, STICKY, 'Tt'),
  ].join
end