Class: Base

Inherits:
Object
  • Object
show all
Defined in:
lib/restclient/multipart.rb

Direct Known Subclasses

Multipart

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Base

Returns a new instance of Base.



2
3
4
# File 'lib/restclient/multipart.rb', line 2

def initialize(params)
	build_stream(params)
end

Instance Method Details

#build_stream(params) ⇒ Object



6
7
8
9
# File 'lib/restclient/multipart.rb', line 6

def build_stream(params)
	@stream = StringIO.new(params)
	@stream.seek(0)
end

#closeObject



33
34
35
# File 'lib/restclient/multipart.rb', line 33

def close
	@stream.close
end

#escape(v) ⇒ Object



20
21
22
# File 'lib/restclient/multipart.rb', line 20

def escape(v)
	URI.escape(v.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
end

#headersObject



24
25
26
# File 'lib/restclient/multipart.rb', line 24

def headers
	{ 'Content-Length' => size.to_s }
end

#read(bytes = nil) ⇒ Object Also known as: to_s



15
16
17
# File 'lib/restclient/multipart.rb', line 15

def read(bytes=nil)
	@stream.read(bytes)
end

#rewindObject



11
12
13
# File 'lib/restclient/multipart.rb', line 11

def rewind
 @stream.seek(0)
end

#sizeObject Also known as: length



28
29
30
# File 'lib/restclient/multipart.rb', line 28

def size
	@stream.size
end