File: name.rb

package info (click to toggle)
ruby-net-sftp 1%3A4.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 684 kB
  • sloc: ruby: 5,136; makefile: 6
file content (43 lines) | stat: -rw-r--r-- 1,565 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
module Net; module SFTP; module Protocol; module V01

  # Represents a single named item on the remote server. This includes the
  # name, attributes about the item, and the "longname", which is intended
  # for use when displaying directory data, and has no specified format.
  class Name
    # The name of the item on the remote server.
    attr_reader :name

    # The display-ready name of the item, possibly with other attributes.
    attr_reader :longname

    # The Attributes object describing this item.
    attr_reader :attributes

    # Create a new Name object with the given name, longname, and attributes.
    def initialize(name, longname, attributes)
      @name, @longname, @attributes = name, longname, attributes
    end

    # Returns +true+ if the item appears to be a directory. It does this by
    # examining the attributes. If there is insufficient information in the
    # attributes, this will return nil, rather than a boolean.
    def directory?
      attributes.directory?
    end

    # Returns +true+ if the item appears to be a symlink. It does this by
    # examining the attributes. If there is insufficient information in the
    # attributes, this will return nil, rather than a boolean.
    def symlink?
      attributes.symlink?
    end

    # Returns +true+ if the item appears to be a regular file. It does this by
    # examining the attributes. If there is insufficient information in the
    # attributes, this will return nil, rather than a boolean.
    def file?
      attributes.file?
    end
  end

end; end; end; end