Class: HttpStreamFormat
- Inherits:
-
Format
- Object
- Format
- HttpStreamFormat
- Defined in:
- lib/httpstreamformat.rb
Instance Attribute Summary collapse
-
#close ⇒ Object
Returns the value of attribute close.
-
#content ⇒ Object
Returns the value of attribute content.
Instance Method Summary collapse
- #export ⇒ Object
-
#initialize(content = nil, close = false) ⇒ HttpStreamFormat
constructor
A new instance of HttpStreamFormat.
- #name ⇒ Object
Constructor Details
#initialize(content = nil, close = false) ⇒ HttpStreamFormat
Returns a new instance of HttpStreamFormat.
15 16 17 18 19 20 21 |
# File 'lib/httpstreamformat.rb', line 15 def initialize(content=nil, close=false) @content = content @close = close if !@close and @content.nil? raise 'Content not set' end end |
Instance Attribute Details
#close ⇒ Object
Returns the value of attribute close.
13 14 15 |
# File 'lib/httpstreamformat.rb', line 13 def close @close end |
#content ⇒ Object
Returns the value of attribute content.
12 13 14 |
# File 'lib/httpstreamformat.rb', line 12 def content @content end |
Instance Method Details
#export ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/httpstreamformat.rb', line 27 def export out = Hash.new if @close out['action'] = 'close' else if @content.encoding.name == 'ASCII-8BIT' out['body-bin'] = Base64.encode64(@content) else out['body'] = @content end end return out end |
#name ⇒ Object
23 24 25 |
# File 'lib/httpstreamformat.rb', line 23 def name return 'http-stream' end |