Class: RSence::Response::ResponseBody

Inherits:
Array
  • Object
show all
Defined in:
lib/rsence/http/response.rb

Overview

Adds the + method “operator” to an extended Array. Used for pushing http body data.

Instance Method Summary collapse

Instance Method Details

#+(body_data) ⇒ Object



34
35
36
# File 'lib/rsence/http/response.rb', line 34

def +(body_data)
  self.push(body_data)
end

#push(body_data) ⇒ Object



20
21
22
# File 'lib/rsence/http/response.rb', line 20

def push( body_data )
  super( sanitize_body_data( body_data ) )
end

#sanitize_body_data(body_data) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rsence/http/response.rb', line 23

def sanitize_body_data( body_data )
  if body_data.class == String or body_data.class == GZString
    return body_data
  elsif body_data.respond_to?(:to_s)
    warn "WARNING: RSence::Response::ResponseBody -> body_data is not a string. It's a #{body_data.class}, with the following contents: #{body_data.inspect}" if RSence.args[:verbose]
    return body_data.to_s
  else
    warn "Invalid response data: #{body_data.inspect[0..100]}"
    return ''
  end
end