Class: RestMan::Payload::Base
- Inherits:
-
Object
- Object
- RestMan::Payload::Base
show all
- Defined in:
- lib/restman/payload/base.rb
Instance Method Summary
collapse
Constructor Details
#initialize(params) ⇒ Base
Returns a new instance of Base.
6
7
8
|
# File 'lib/restman/payload/base.rb', line 6
def initialize(params)
build_stream(params)
end
|
Instance Method Details
#build_stream(params) ⇒ Object
10
11
12
13
|
# File 'lib/restman/payload/base.rb', line 10
def build_stream(params)
@stream = StringIO.new(params)
@stream.seek(0)
end
|
#close ⇒ Object
35
36
37
|
# File 'lib/restman/payload/base.rb', line 35
def close
@stream.close unless @stream.closed?
end
|
#closed? ⇒ Boolean
39
40
41
|
# File 'lib/restman/payload/base.rb', line 39
def closed?
@stream.closed?
end
|
25
26
27
|
# File 'lib/restman/payload/base.rb', line 25
def
{'Content-Length' => size.to_s}
end
|
#read(*args) ⇒ Object
15
16
17
|
# File 'lib/restman/payload/base.rb', line 15
def read(*args)
@stream.read(*args)
end
|
#short_inspect ⇒ Object
47
48
49
50
51
52
53
|
# File 'lib/restman/payload/base.rb', line 47
def short_inspect
if size && size > 500
"#{size} byte(s) length"
else
to_s_inspect
end
end
|
#size ⇒ Object
Also known as:
length
29
30
31
|
# File 'lib/restman/payload/base.rb', line 29
def size
@stream.size
end
|
#to_s ⇒ Object
19
20
21
22
23
|
# File 'lib/restman/payload/base.rb', line 19
def to_s
result = read
@stream.seek(0)
result
end
|
#to_s_inspect ⇒ Object
43
44
45
|
# File 'lib/restman/payload/base.rb', line 43
def to_s_inspect
to_s.inspect
end
|