Class: Net::FTP::MLSxEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/net/ftp.rb

Overview

MLSxEntry represents an entry in responses of MLST/MLSD. Each entry has the facts (e.g., size, last modification time, etc.) and the pathname.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(facts, pathname) ⇒ MLSxEntry

Returns a new instance of MLSxEntry.


950
951
952
953
# File 'lib/net/ftp.rb', line 950

def initialize(facts, pathname)
  @facts = facts
  @pathname = pathname
end

Instance Attribute Details

#factsObject (readonly)

Returns the value of attribute facts.


948
949
950
# File 'lib/net/ftp.rb', line 948

def facts
  @facts
end

#pathnameObject (readonly)

Returns the value of attribute pathname.


948
949
950
# File 'lib/net/ftp.rb', line 948

def pathname
  @pathname
end

Instance Method Details

#appendable?Boolean

Returns true if the APPE command may be applied to the file.

Returns:

  • (Boolean)

986
987
988
# File 'lib/net/ftp.rb', line 986

def appendable?
  return facts["perm"].include?(?a)
end

#creatable?Boolean

Returns true if files may be created in the directory by STOU, STOR, APPE, and RNTO.

Returns:

  • (Boolean)

994
995
996
# File 'lib/net/ftp.rb', line 994

def creatable?
  return facts["perm"].include?(?c)
end

#deletable?Boolean

Returns true if the file or directory may be deleted by DELE/RMD.

Returns:

  • (Boolean)

1001
1002
1003
# File 'lib/net/ftp.rb', line 1001

def deletable?
  return facts["perm"].include?(?d)
end

#directory?Boolean

Returns true if the entry is a directory (i.e., the value of the type fact is dir, cdir, or pdir).

Returns:

  • (Boolean)

975
976
977
978
979
980
981
# File 'lib/net/ftp.rb', line 975

def directory?
  if /\A[cp]?dir\z/.match(facts["type"])
    return true
  else
    return false
  end
end

#directory_makable?Boolean

Returns true if the MKD command may be used to create a new directory within the directory.

Returns:

  • (Boolean)

1031
1032
1033
# File 'lib/net/ftp.rb', line 1031

def directory_makable?
  return facts["perm"].include?(?m)
end

#enterable?Boolean

Returns true if the directory may be entered by CWD/CDUP.

Returns:

  • (Boolean)

1008
1009
1010
# File 'lib/net/ftp.rb', line 1008

def enterable?
  return facts["perm"].include?(?e)
end

#file?Boolean

Returns true if the entry is a file (i.e., the value of the type fact is file).

Returns:

  • (Boolean)

967
968
969
# File 'lib/net/ftp.rb', line 967

def file?
  return facts["type"] == "file"
end

#listable?Boolean

Returns true if the listing commands, LIST, NLST, and MLSD are applied to the directory.

Returns:

  • (Boolean)

1023
1024
1025
# File 'lib/net/ftp.rb', line 1023

def listable?
  return facts["perm"].include?(?l)
end

#purgeable?Boolean

Returns true if the objects in the directory may be deleted, or the directory may be purged.

Returns:

  • (Boolean)

1039
1040
1041
# File 'lib/net/ftp.rb', line 1039

def purgeable?
  return facts["perm"].include?(?p)
end

#readable?Boolean

Returns true if the RETR command may be applied to the file.

Returns:

  • (Boolean)

1046
1047
1048
# File 'lib/net/ftp.rb', line 1046

def readable?
  return facts["perm"].include?(?r)
end

#renamable?Boolean

Returns true if the file or directory may be renamed by RNFR.

Returns:

  • (Boolean)

1015
1016
1017
# File 'lib/net/ftp.rb', line 1015

def renamable?
  return facts["perm"].include?(?f)
end

#writable?Boolean

Returns true if the STOR command may be applied to the file.

Returns:

  • (Boolean)

1053
1054
1055
# File 'lib/net/ftp.rb', line 1053

def writable?
  return facts["perm"].include?(?w)
end