Class: RftpFile

Inherits:
Object
  • Object
show all
Defined in:
lib/rftp.rb

Direct Known Subclasses

RftpDirectory

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parts, parent) ⇒ RftpFile

Returns a new instance of RftpFile.



22
23
24
25
26
# File 'lib/rftp.rb', line 22

def initialize(parts, parent)
  self.path = "#{parent.path}/#{parts.last}"
  self.parent = parent
  parse_parts(parts)
end

Instance Attribute Details

#groupObject

Returns the value of attribute group.



12
13
14
# File 'lib/rftp.rb', line 12

def group
  @group
end

#last_modifiedObject

Returns the value of attribute last_modified.



12
13
14
# File 'lib/rftp.rb', line 12

def last_modified
  @last_modified
end

#nameObject

Returns the value of attribute name.



12
13
14
# File 'lib/rftp.rb', line 12

def name
  @name
end

#ownerObject

Returns the value of attribute owner.



12
13
14
# File 'lib/rftp.rb', line 12

def owner
  @owner
end

#parentObject

Returns the value of attribute parent.



11
12
13
# File 'lib/rftp.rb', line 11

def parent
  @parent
end

#pathObject

Returns the value of attribute path.



12
13
14
# File 'lib/rftp.rb', line 12

def path
  @path
end

#permissionsObject

Returns the value of attribute permissions.



12
13
14
# File 'lib/rftp.rb', line 12

def permissions
  @permissions
end

#sizeObject

Returns the value of attribute size.



12
13
14
# File 'lib/rftp.rb', line 12

def size
  @size
end

Instance Method Details

#connectionObject



37
38
39
# File 'lib/rftp.rb', line 37

def connection
  parent.connection
end

#contentsObject



41
42
43
44
45
46
47
# File 'lib/rftp.rb', line 41

def contents
  c = ""
  connection.retrlines("RETR #{self.path}") do |line|
    c += line + "\n"
  end
  c
end

#dir?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/rftp.rb', line 18

def dir?
  false
end

#file?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/rftp.rb', line 14

def file?
  true
end

#parse_parts(parts) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/rftp.rb', line 28

def parse_parts(parts)
  self.permissions = parts[0]
  self.owner = parts[2]
  self.group = parts[3]
  self.size = parts[4]
  self.last_modified = DateTime.parse("#{parts[5]} #{parts[6]} #{parts[8]} #{parts[7]}")
  self.name = parts.last
end