class Rake::FtpFile
Note: Not released for general use.
Attributes
group[R]
name[R]
owner[R]
size[R]
time[R]
Public Class Methods
date()
click to toggle source
# File lib/rake/contrib/ftptools.rb, line 17 def self.date @date_class ||= Date end
new(path, entry)
click to toggle source
# File lib/rake/contrib/ftptools.rb, line 25 def initialize(path, entry) @path = path @mode, _, @owner, @group, size, d1, d2, d3, @name = entry.split(' ') @size = size.to_i @time = determine_time(d1, d2, d3) end
time()
click to toggle source
# File lib/rake/contrib/ftptools.rb, line 21 def self.time @time_class ||= Time end
Public Instance Methods
directory?()
click to toggle source
# File lib/rake/contrib/ftptools.rb, line 36 def directory? @mode[0] == ?d end
mode()
click to toggle source
# File lib/rake/contrib/ftptools.rb, line 40 def mode parse_mode(@mode) end
path()
click to toggle source
# File lib/rake/contrib/ftptools.rb, line 32 def path File.join(@path, @name) end
symlink?()
click to toggle source
# File lib/rake/contrib/ftptools.rb, line 44 def symlink? @mode[0] == ?l end
Private Instance Methods
determine_time(d1, d2, d3)
click to toggle source
# File lib/rake/contrib/ftptools.rb, line 58 def determine_time(d1, d2, d3) now = self.class.time.now if /:/ =~ d3 result = Time.parse("#{d1} #{d2} #{now.year} #{d3}") if result > now result = Time.parse("#{d1} #{d2} #{now.year-1} #{d3}") end else result = Time.parse("#{d1} #{d2} #{d3}") end result # elements = ParseDate.parsedate("#{d1} #{d2} #{d3}") # if elements[0].nil? # today = self.class.date.today # if elements[1] > today.month # elements[0] = today.year - 1 # else # elements[0] = today.year # end # end # elements = elements.collect { |el| el.nil? ? 0 : el } # Time.mktime(*elements[0,7]) end
parse_mode(m)
click to toggle source
# File lib/rake/contrib/ftptools.rb, line 50 def parse_mode(m) result = 0 (1..9).each do |i| result = 2*result + ((m[i]==?-) ? 0 : 1) end result end