Class: Net::NNTP::CapabilityList

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

Overview

Code: 101

Response to a Capabilities request.

Instance Attribute Summary collapse

Attributes inherited from Response

#code, #message, #request

Instance Method Summary collapse

Methods included from BodyBaseResponse

#body, #body=

Methods inherited from Response

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

Constructor Details

#initialize(request, code, message) ⇒ CapabilityList

Returns a new instance of CapabilityList.



171
172
173
174
# File 'lib/net/nntp/response.rb', line 171

def initialize(request, code, message)
  @capabilities = {}
  super request, code, message, false, true
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



169
170
171
# File 'lib/net/nntp/response.rb', line 169

def raw
  @raw
end

Instance Method Details

#capabilitiesObject

Returns the capabilities as a hash. Key is the first word (capability) downcased, value either a single string or a array of strings, or the value ‘true’.



179
180
181
# File 'lib/net/nntp/response.rb', line 179

def capabilities
  @capabilities.dup
end

#parse_bodyObject

:nodoc: internal use only



182
183
184
185
186
187
188
189
# File 'lib/net/nntp/response.rb', line 182

def parse_body # :nodoc: internal use only
  @raw.split(/\n/).each do |line|
    break if line == '.'
    key, *value = line.split(/\s+/)
    value = (value.size <= 1 ? value[0]: value) 
    @capabilities[key.downcase]= value || true
  end unless @raw.nil?
end