Class: RestClient::Payload::Base
- Inherits:
-
Object
- Object
- RestClient::Payload::Base
- Defined in:
- lib/vendor/rest-client/lib/rest_client/payload.rb
Direct Known Subclasses
Instance Method Summary collapse
- #build_stream(params) ⇒ Object
- #close ⇒ Object
- #escape(v) ⇒ Object
- #headers ⇒ Object
-
#initialize(params) ⇒ Base
constructor
A new instance of Base.
- #read(bytes = nil) ⇒ Object (also: #to_s)
- #size ⇒ Object (also: #length)
Constructor Details
#initialize(params) ⇒ Base
Returns a new instance of Base.
20 21 22 |
# File 'lib/vendor/rest-client/lib/rest_client/payload.rb', line 20 def initialize(params) build_stream(params) end |
Instance Method Details
#build_stream(params) ⇒ Object
24 25 26 27 |
# File 'lib/vendor/rest-client/lib/rest_client/payload.rb', line 24 def build_stream(params) @stream = StringIO.new(params) @stream.seek(0) end |
#close ⇒ Object
47 48 49 |
# File 'lib/vendor/rest-client/lib/rest_client/payload.rb', line 47 def close @stream.close end |
#escape(v) ⇒ Object
34 35 36 |
# File 'lib/vendor/rest-client/lib/rest_client/payload.rb', line 34 def escape(v) URI.escape(v.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")) end |
#headers ⇒ Object
38 39 40 |
# File 'lib/vendor/rest-client/lib/rest_client/payload.rb', line 38 def headers { 'Content-Length' => size.to_s } end |
#read(bytes = nil) ⇒ Object Also known as: to_s
29 30 31 |
# File 'lib/vendor/rest-client/lib/rest_client/payload.rb', line 29 def read(bytes=nil) @stream.read(bytes) end |
#size ⇒ Object Also known as: length
42 43 44 |
# File 'lib/vendor/rest-client/lib/rest_client/payload.rb', line 42 def size @stream.size end |