Class: RftpFile
- Inherits:
-
Object
- Object
- RftpFile
- Defined in:
- lib/rftp.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#group ⇒ Object
Returns the value of attribute group.
-
#last_modified ⇒ Object
Returns the value of attribute last_modified.
-
#name ⇒ Object
Returns the value of attribute name.
-
#owner ⇒ Object
Returns the value of attribute owner.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#path ⇒ Object
Returns the value of attribute path.
-
#permissions ⇒ Object
Returns the value of attribute permissions.
-
#size ⇒ Object
Returns the value of attribute size.
Instance Method Summary collapse
- #connection ⇒ Object
- #contents ⇒ Object
- #dir? ⇒ Boolean
- #file? ⇒ Boolean
-
#initialize(parts, parent) ⇒ RftpFile
constructor
A new instance of RftpFile.
- #parse_parts(parts) ⇒ Object
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
#group ⇒ Object
Returns the value of attribute group.
12 13 14 |
# File 'lib/rftp.rb', line 12 def group @group end |
#last_modified ⇒ Object
Returns the value of attribute last_modified.
12 13 14 |
# File 'lib/rftp.rb', line 12 def last_modified @last_modified end |
#name ⇒ Object
Returns the value of attribute name.
12 13 14 |
# File 'lib/rftp.rb', line 12 def name @name end |
#owner ⇒ Object
Returns the value of attribute owner.
12 13 14 |
# File 'lib/rftp.rb', line 12 def owner @owner end |
#parent ⇒ Object
Returns the value of attribute parent.
11 12 13 |
# File 'lib/rftp.rb', line 11 def parent @parent end |
#path ⇒ Object
Returns the value of attribute path.
12 13 14 |
# File 'lib/rftp.rb', line 12 def path @path end |
#permissions ⇒ Object
Returns the value of attribute permissions.
12 13 14 |
# File 'lib/rftp.rb', line 12 def @permissions end |
#size ⇒ Object
Returns the value of attribute size.
12 13 14 |
# File 'lib/rftp.rb', line 12 def size @size end |
Instance Method Details
#connection ⇒ Object
37 38 39 |
# File 'lib/rftp.rb', line 37 def connection parent.connection end |
#contents ⇒ Object
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
18 19 20 |
# File 'lib/rftp.rb', line 18 def dir? false end |
#file? ⇒ 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. = 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 |