Class: RestFtpDaemon::Path

Inherits:
Object
  • Object
show all
Defined in:
lib/rest-ftp-daemon/path.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(full, strip_leading_slash = false) ⇒ Path

Returns a new instance of Path.



6
7
8
9
10
11
12
13
# File 'lib/rest-ftp-daemon/path.rb', line 6

def initialize full, strip_leading_slash = false
  # Extract path parts
  @name = extract_filename full.to_s
  @dir = extract_dirname full.to_s

  # Remove leading slash if needed
  strip_leading_slash_from_dir! if strip_leading_slash
end

Instance Attribute Details

#dirObject

Returns the value of attribute dir.



4
5
6
# File 'lib/rest-ftp-daemon/path.rb', line 4

def dir
  @dir
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/rest-ftp-daemon/path.rb', line 3

def name
  @name
end

Instance Method Details

#fullObject



15
16
17
18
19
20
21
# File 'lib/rest-ftp-daemon/path.rb', line 15

def full
  if @dir.nil? || @dir.empty?
    return @name
  else
    return File.join @dir, @name
  end
end

#sizeObject



23
24
25
# File 'lib/rest-ftp-daemon/path.rb', line 23

def size
  File.size full if File.exist? full
end