Class: Net::NNTP::CapabilityList
- Inherits:
-
InformationResponse
- Object
- Response
- InformationResponse
- Net::NNTP::CapabilityList
- Defined in:
- lib/net/nntp/response.rb
Overview
Code: 101
Response to a Capabilities request.
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Attributes inherited from Response
Instance Method Summary collapse
-
#capabilities ⇒ Object
Returns the capabilities as a hash.
-
#initialize(request, code, message) ⇒ CapabilityList
constructor
A new instance of CapabilityList.
-
#parse_body ⇒ Object
:nodoc: internal use only.
Methods included from BodyBaseResponse
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, ) @capabilities = {} super request, code, , false, true end |
Instance Attribute Details
#raw ⇒ Object (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
#capabilities ⇒ Object
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_body ⇒ Object
: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 |