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.
60
61
62
|
# File 'lib/restclient/payload.rb', line 60
def initialize(params)
build_stream(params)
end
|
Instance Method Details
#build_stream(params) ⇒ Object
64
65
66
67
|
# File 'lib/restclient/payload.rb', line 64
def build_stream(params)
@stream = StringIO.new(params)
@stream.seek(0)
end
|
#close ⇒ Object
89
90
91
|
# File 'lib/restclient/payload.rb', line 89
def close
@stream.close unless @stream.closed?
end
|
#closed? ⇒ Boolean
93
94
95
|
# File 'lib/restclient/payload.rb', line 93
def closed?
@stream.closed?
end
|
79
80
81
|
# File 'lib/restclient/payload.rb', line 79
def
{'Content-Length' => size.to_s}
end
|
#read(*args) ⇒ Object
69
70
71
|
# File 'lib/restclient/payload.rb', line 69
def read(*args)
@stream.read(*args)
end
|
#short_inspect ⇒ Object
101
102
103
104
105
106
107
|
# File 'lib/restclient/payload.rb', line 101
def short_inspect
if size && size > 500
"#{size} byte(s) length"
else
to_s_inspect
end
end
|
#size ⇒ Object
Also known as:
length
83
84
85
|
# File 'lib/restclient/payload.rb', line 83
def size
@stream.size
end
|
#to_s ⇒ Object
73
74
75
76
77
|
# File 'lib/restclient/payload.rb', line 73
def to_s
result = read
@stream.seek(0)
result
end
|
#to_s_inspect ⇒ Object
97
98
99
|
# File 'lib/restclient/payload.rb', line 97
def to_s_inspect
to_s.inspect
end
|