Class: HttpResponseFormat
- Inherits:
-
Format
- Object
- Format
- HttpResponseFormat
- Defined in:
- lib/httpresponseformat.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#code ⇒ Object
Returns the value of attribute code.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#reason ⇒ Object
Returns the value of attribute reason.
Instance Method Summary collapse
- #export ⇒ Object
-
#initialize(code = nil, reason = nil, headers = nil, body = nil) ⇒ HttpResponseFormat
constructor
A new instance of HttpResponseFormat.
- #name ⇒ Object
Constructor Details
#initialize(code = nil, reason = nil, headers = nil, body = nil) ⇒ HttpResponseFormat
Returns a new instance of HttpResponseFormat.
17 18 19 20 21 22 |
# File 'lib/httpresponseformat.rb', line 17 def initialize(code=nil, reason=nil, headers=nil, body=nil) @code = code @reason = reason @headers = headers @body = body end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
15 16 17 |
# File 'lib/httpresponseformat.rb', line 15 def body @body end |
#code ⇒ Object
Returns the value of attribute code.
12 13 14 |
# File 'lib/httpresponseformat.rb', line 12 def code @code end |
#headers ⇒ Object
Returns the value of attribute headers.
14 15 16 |
# File 'lib/httpresponseformat.rb', line 14 def headers @headers end |
#reason ⇒ Object
Returns the value of attribute reason.
13 14 15 |
# File 'lib/httpresponseformat.rb', line 13 def reason @reason end |
Instance Method Details
#export ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/httpresponseformat.rb', line 28 def export out = Hash.new if !@code.nil? out['code'] = @code end if !@reason.nil? out['reason'] = @reason end if !@headers.nil? and @headers.length > 0 out['headers'] = @headers end if !@body.nil? if @body.encoding.name == 'ASCII-8BIT' out['body-bin'] = Base64.encode64(@body) else out['body'] = @body end end return out end |
#name ⇒ Object
24 25 26 |
# File 'lib/httpresponseformat.rb', line 24 def name return 'http-response' end |