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



100
101
102
# File 'lib/ftpd/list_format/ls.rb', line 100

def initialize(mode)
  @mode = mode
end

Instance Method Details

#lettersObject

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



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

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