Class: RestClient::Payload::Base
- Inherits:
-
Object
- Object
- RestClient::Payload::Base
show all
- Defined in:
- lib/restclient/payload.rb
Instance Method Summary
collapse
Constructor Details
#initialize(params) ⇒ Base
Returns a new instance of Base.
46
47
48
|
# File 'lib/restclient/payload.rb', line 46
def initialize(params)
build_stream(params)
end
|
Instance Method Details
#build_stream(params) ⇒ Object
50
51
52
53
|
# File 'lib/restclient/payload.rb', line 50
def build_stream(params)
@stream = StringIO.new(params)
@stream.seek(0)
end
|
#close ⇒ Object
75
76
77
|
# File 'lib/restclient/payload.rb', line 75
def close
@stream.close unless @stream.closed?
end
|
65
66
67
|
# File 'lib/restclient/payload.rb', line 65
def
{'Content-Length' => size.to_s}
end
|
#read(*args) ⇒ Object
55
56
57
|
# File 'lib/restclient/payload.rb', line 55
def read(*args)
@stream.read(*args)
end
|
#short_inspect ⇒ Object
83
84
85
|
# File 'lib/restclient/payload.rb', line 83
def short_inspect
(size > 500 ? "#{size} byte(s) length" : to_s_inspect)
end
|
#size ⇒ Object
Also known as:
length
69
70
71
|
# File 'lib/restclient/payload.rb', line 69
def size
@stream.size
end
|
#to_s ⇒ Object
59
60
61
62
63
|
# File 'lib/restclient/payload.rb', line 59
def to_s
result = read
@stream.seek(0)
result
end
|
#to_s_inspect ⇒ Object
79
80
81
|
# File 'lib/restclient/payload.rb', line 79
def to_s_inspect
to_s.inspect
end
|