Class: Gopher::Response

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

Overview

basic class for server response to a request. contains the rendered results, a code that indicates success/failure, and can report the size of the response

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



9
10
11
# File 'lib/gopher2000/response.rb', line 9

def body
  @body
end

#codeObject

Returns the value of attribute code.



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

def code
  @code
end

Instance Method Details

#sizeInteger

get the size, in bytes, of the response. used for logging

Returns:

  • (Integer)

    size



16
17
18
19
20
21
22
23
# File 'lib/gopher2000/response.rb', line 16

def size
  case self.body
  when String then self.body.length
  when StringIO then self.body.length
  when File then self.body.size
  else 0
  end
end