Class: Net::SFTP::Protocol::V01::Name

Inherits:
Object
  • Object
show all
Defined in:
lib/net/sftp/protocol/01/name.rb

Overview

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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, longname, attributes) ⇒ Name

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



17
18
19
# File 'lib/net/sftp/protocol/01/name.rb', line 17

def initialize(name, longname, attributes)
  @name, @longname, @attributes = name, longname, attributes
end

Instance Attribute Details

#attributesObject (readonly)

The Attributes object describing this item.



14
15
16
# File 'lib/net/sftp/protocol/01/name.rb', line 14

def attributes
  @attributes
end

#longnameObject (readonly)

The display-ready name of the item, possibly with other attributes.



11
12
13
# File 'lib/net/sftp/protocol/01/name.rb', line 11

def longname
  @longname
end

#nameObject (readonly)

The name of the item on the remote server.



8
9
10
# File 'lib/net/sftp/protocol/01/name.rb', line 8

def name
  @name
end

Instance Method Details

#directory?Boolean

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.

Returns:

  • (Boolean)


24
25
26
# File 'lib/net/sftp/protocol/01/name.rb', line 24

def directory?
  attributes.directory?
end

#file?Boolean

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.

Returns:

  • (Boolean)


38
39
40
# File 'lib/net/sftp/protocol/01/name.rb', line 38

def file?
  attributes.file?
end

#symlink?Boolean

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.

Returns:

  • (Boolean)


31
32
33
# File 'lib/net/sftp/protocol/01/name.rb', line 31

def symlink?
  attributes.symlink?
end