Class: Net::NNTP::ListInformationFollows

Inherits:
GroupListResponse show all
Defined in:
lib/net/nntp/response.rb

Overview

Code: 215

Instance Attribute Summary

Attributes inherited from GroupListResponse

#list, #raw

Attributes inherited from Response

#code, #message, #request

Instance Method Summary collapse

Methods inherited from GroupListResponse

#initialize

Methods included from BodyBaseResponse

#body, #body=

Methods inherited from Response

#==, #body, class_from_code, create, #force_close?, #generic?, #has_body?, #initialize, #multiline?, #needs_article?

Constructor Details

This class inherits a constructor from Net::NNTP::GroupListResponse

Instance Method Details

#parse_bodyObject



282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
# File 'lib/net/nntp/response.rb', line 282

def parse_body
  case @request.keyword
  when nil, 'ACTIVE'
    @raw.split(/\r?\n/).each do |line|
      break if line == '.'
      name, low, high, status = line.split(/\s+/)
      @list << OpenStruct.new(:name => name, :low => low.to_i, :high => high.to_i, :status => status.strip)
    end unless @raw.nil?
  when 'ACTIVE.TIMES'
    @raw.split(/\r?\n/).each do |line|
      break if line == '.'
      name, epoch, creator = line.split(/\s+/)
      @list << OpenStruct.new(:name => name, :epoch => epoch, :creator => creator)
    end unless @raw.nil?
  when 'DISTRIB.PATS'
    @raw.split(/\r?\n/).each do |line|
      break if line == '.'
      priority, pattern, distribution = line.split(/:/)
      @list << OpenStruct.new(:priority => priority.to_i, :pattern => pattern, :distribution => distribution)
    end unless @raw.nil?
  when 'HEADERS'
    @list = @raw.gsub(/\r?\n\.\r?\n/, '').split(/\r?\n/) unless @raw.nil?
  when 'NEWSGROUPS'
    @raw.split(/\r?\n/).each do |line|
      break if line == '.'
      if match = line.match(/\A(\S+)\s+(.*)\z/)
        name, desc = match.captures
        @list << OpenStruct.new(:name => name, :desc => desc)
      else
        raise ProtocolError,'List format mismatch'
      end
    end unless @raw.nil?
  when 'OVERVIEW.FMT'
    @raw.split(/\r?\n/).each do |line|
      break if line == '.'
      @list << FormatHeader.new(line)
    end unless @raw.nil?
  end
end