Sha256: 523f11a19c2bea433d090f39b140b3995dfa82935b1b2f397d708fec607080a5

Contents?: true

Size: 890 Bytes

Versions: 12

Compression:

Stored size: 890 Bytes

Contents

# Abstract FTP LIST parser. It really just defines and documents the interface.
class Net::FTP::List::Parser

  @@parsers = []

  # Run a passed block with each parser in succession, from the most specific to the least
  # specific. Will return the result of the block.
  def self.with_each_parser(&blk) #:yields: parser
    @@parsers.each(&blk)
  end

  # Automatically add an inheriting parser to the list of known parsers.
  def self.inherited(klass) #:nodoc:
    @@parsers.push(klass)
  end

  # The main parse method. Return false from it if parsing fails (this is cheaper than raising an exception)
  def self.parse(raw)
    return false
  end

  private

  # Automatically adds the name of the parser class to the server_type field
  def self.emit_entry(raw, extra_attributes)
    Net::FTP::List::Entry.new raw, extra_attributes.merge(:server_type => to_s.split('::').pop)
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
net-ftp-list-3.2.11 lib/net/ftp/list/parser.rb
net-ftp-list-3.2.10 lib/net/ftp/list/parser.rb
net-ftp-list-3.2.9 lib/net/ftp/list/parser.rb
net-ftp-list-3.2.8 lib/net/ftp/list/parser.rb
net-ftp-list-3.2.7 lib/net/ftp/list/parser.rb
net-ftp-list-3.2.6 lib/net/ftp/list/parser.rb
net-ftp-list-3.2.5 lib/net/ftp/list/parser.rb
net-ftp-list-3.2.4 lib/net/ftp/list/parser.rb
net-ftp-list-3.2.3 lib/net/ftp/list/parser.rb
net-ftp-list-3.2.2 lib/net/ftp/list/parser.rb
net-ftp-list-3.2.1 lib/net/ftp/list/parser.rb
net-ftp-list-3.2.0 lib/net/ftp/list/parser.rb