Class: RestClient::Payload::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/vendor/rest-client/lib/rest_client/payload.rb

Direct Known Subclasses

Multipart, UrlEncoded

Instance Method Summary collapse

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

#closeObject



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

#headersObject



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

#sizeObject Also known as: length



42
43
44
# File 'lib/vendor/rest-client/lib/rest_client/payload.rb', line 42

def size
	@stream.size
end