Class: Net::NNTPResponse

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

Constant Summary collapse

PARSE_RE =
/^(\d{3})\s*(.*)/

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ NNTPResponse

Returns a new instance of NNTPResponse.


16
17
18
# File 'lib/net/nntp/response.rb', line 16

def initialize(raw)
  @raw = raw
end

Instance Attribute Details

#codeInteger (readonly)

Returns the response code.

Returns:

  • (Integer)

    the response code


8
9
10
# File 'lib/net/nntp/response.rb', line 8

def code
  @code
end

#messageString (readonly)

Returns the response message.

Returns:

  • (String)

    the response message


10
11
12
# File 'lib/net/nntp/response.rb', line 10

def message
  @message
end

#rawString (readonly)

Returns the raw response.

Returns:

  • (String)

    the raw response


6
7
8
# File 'lib/net/nntp/response.rb', line 6

def raw
  @raw
end

Class Method Details

.parse(raw) ⇒ Object


12
13
14
# File 'lib/net/nntp/response.rb', line 12

def self.parse(raw)
  new(raw).tap { |resp| resp.parse }
end

Instance Method Details

#has_long_response?Boolean

Returns:

  • (Boolean)

25
26
27
# File 'lib/net/nntp/response.rb', line 25

def has_long_response?
  false
end

#parseObject


20
21
22
23
# File 'lib/net/nntp/response.rb', line 20

def parse
  @code     = @raw[PARSE_RE, 1].to_i
  @message  = @raw[PARSE_RE, 2]
end

#to_sObject


29
30
31
# File 'lib/net/nntp/response.rb', line 29

def to_s
  "#{self.class} code: #{code} message: #{message}"
end