Class: Net::FTP::List::Rumpus

Inherits:
Parser
  • Object
show all
Defined in:
lib/net/ftp/list/rumpus.rb

Overview

Parse Rumpus FTP LIST entries.

MATCHES

drwxr-xr-x folder 0 Nov 30 10:03 houdini -rw-r--r-- 0 101426 101426 Jun 7 2008 imap with spaces.rb

Constant Summary

REGEXP =
%r!^
  ([drwxr-]{10})\s+
  (folder|0\s+\d+)\s+
  (\d+)\s+
  (\w+)\s+
  (\d{1,2})\s+
  (\d{2}:\d{2}|\d{4})\s+
  (.+)
$!x

Class Method Summary collapse

Class Method Details

.parse(raw) ⇒ Object

Parse a Rumpus FTP LIST entry.



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/net/ftp/list/rumpus.rb', line 21

def self.parse(raw)
  match = REGEXP.match(raw.strip) or return false

  emit_entry(
    raw,
    :basename => match[7],
    :mtime => Time.parse([match[4], match[5], match[6]].join(" ")),
    :file => !(match[2] == "folder"),
    :dir => (match[2] == "folder"),
    :filesize => match[3].to_i
  )
end