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



26
27
28
# File 'lib/rsence/http/response.rb', line 26

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

#push(body_data) ⇒ Object



12
13
14
# File 'lib/rsence/http/response.rb', line 12

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

#sanitize_body_data(body_data) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rsence/http/response.rb', line 15

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