Class: Net::SFTP::Protocol::V04::Name

### Home Classes Methods

### In Files

- lib/net/sftp/protocol/04/name.rb

### Parent

Object

### Methods

- ::new
- #directory?
- #file?
- #longname
- #symlink?

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- Net
- Net::SFTP
- Net::SFTP::Constants
- Net::SFTP::Constants::ACE
- Net::SFTP::Constants::ACE::Flag
- Net::SFTP::Constants::ACE::Mask
- Net::SFTP::Constants::ACE::Type
- Net::SFTP::Constants::LockTypes
- Net::SFTP::Constants::OpenFlags
- Net::SFTP::Constants::OpenFlags::FV1
- Net::SFTP::Constants::OpenFlags::FV5
- Net::SFTP::Constants::OpenFlags::FV6
- Net::SFTP::Constants::PacketTypes
- Net::SFTP::Constants::RenameFlags
- Net::SFTP::Constants::StatusCodes
- Net::SFTP::Exception
- Net::SFTP::Operations
- Net::SFTP::Operations::Dir
- Net::SFTP::Operations::Download
- Net::SFTP::Operations::File
- Net::SFTP::Operations::FileFactory
- Net::SFTP::Operations::Upload
- Net::SFTP::Packet
- Net::SFTP::Protocol
- Net::SFTP::Protocol::Base
- Net::SFTP::Protocol::V01
- Net::SFTP::Protocol::V01::Attributes
- Net::SFTP::Protocol::V01::Base
- Net::SFTP::Protocol::V01::Name
- Net::SFTP::Protocol::V02
- Net::SFTP::Protocol::V02::Base
- Net::SFTP::Protocol::V03
- Net::SFTP::Protocol::V03::Base
- Net::SFTP::Protocol::V04
- Net::SFTP::Protocol::V04::Attributes
- Net::SFTP::Protocol::V04::Base
- Net::SFTP::Protocol::V04::Name
- Net::SFTP::Protocol::V05
- Net::SFTP::Protocol::V05::Base
- Net::SFTP::Protocol::V06
- Net::SFTP::Protocol::V06::Attributes
- Net::SFTP::Protocol::V06::Base
- Net::SFTP::Request
- Net::SFTP::Response
- Net::SFTP::Session
- Net::SFTP::StatusException
- Net::SFTP::Version
- Net::SSH
- Net::SSH::Connection
- Net::SSH::Connection::Session

No matching classes.

# Net::SFTP::Protocol::V04::Name

Represents a single named item on the remote server. This includes the name, and attributes about the item, and the "longname".

For backwards compatibility with the format and interface of the Name structure from previous protocol versions, this also exposes a longname method, which returns a string that can be used to display this item in a directory listing.

### Attributes

attributes[R]

Attributes instance describing this item.

name[R]

The name of the item on the remote server.

### Public Class Methods

new(name, attributes) click to toggle source

Create a new Name object with the given name and attributes.

    # File lib/net/sftp/protocol/04/name.rb, line 18
    def initialize(name, attributes)
      @name, @attributes = name, attributes
    end

### Public Instance Methods

directory?() click to toggle source

Returns `true` if the item is a directory.

    # File lib/net/sftp/protocol/04/name.rb, line 23
    def directory?
      attributes.directory?
    end

file?() click to toggle source

Returns `true` if the item is a regular file.

    # File lib/net/sftp/protocol/04/name.rb, line 33
    def file?
      attributes.file?
    end

longname() click to toggle source

Returns a string representing this file, in a format similar to that used by the unix "ls" utility.

    # File lib/net/sftp/protocol/04/name.rb, line 39
    def longname
      @longname ||= begin
        longname = if directory?
          "d"
        elsif symlink?
          "l"
        else
          "-"
        end

        longname << (attributes.permissions & 0400 != 0 ? "r" : "-")
        longname << (attributes.permissions & 0200 != 0 ? "w" : "-")
        longname << (attributes.permissions & 0100 != 0 ? "x" : "-")
        longname << (attributes.permissions & 0040 != 0 ? "r" : "-")
        longname << (attributes.permissions & 0020 != 0 ? "w" : "-")
        longname << (attributes.permissions & 0010 != 0 ? "x" : "-")
        longname << (attributes.permissions & 0004 != 0 ? "r" : "-")
        longname << (attributes.permissions & 0002 != 0 ? "w" : "-")
        longname << (attributes.permissions & 0001 != 0 ? "x" : "-")

        longname << (" %-8s %-8s %8d " % [attributes.owner, attributes.group, attributes.size])

        longname << Time.at(attributes.mtime).strftime("%b %e %H:%M ")
        longname << name
      end
    end

symlink?() click to toggle source

Returns `true` if the item is a symlink.

    # File lib/net/sftp/protocol/04/name.rb, line 28
    def symlink?
      attributes.symlink?
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.