Class: HTTP::Message::Body::Parts
- Inherits:
-
Object
- Object
- HTTP::Message::Body::Parts
- Defined in:
- lib/httpclient/http.rb
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #add(part) ⇒ Object
-
#initialize ⇒ Parts
constructor
A new instance of Parts.
- #parts ⇒ Object
Constructor Details
#initialize ⇒ Parts
Returns a new instance of Parts.
611 612 613 614 615 |
# File 'lib/httpclient/http.rb', line 611 def initialize @body = [] @size = 0 @as_stream = false end |
Instance Attribute Details
#size ⇒ Object (readonly)
Returns the value of attribute size.
609 610 611 |
# File 'lib/httpclient/http.rb', line 609 def size @size end |
Instance Method Details
#add(part) ⇒ Object
617 618 619 620 621 622 623 624 625 626 627 628 629 630 |
# File 'lib/httpclient/http.rb', line 617 def add(part) if Message.file?(part) @as_stream = true @body << part # use chunked upload @size = nil elsif @body[-1].is_a?(String) @body[-1] += part.to_s @size += part.to_s.bytesize if @size else @body << part.to_s @size += part.to_s.bytesize if @size end end |
#parts ⇒ Object
632 633 634 635 636 637 638 |
# File 'lib/httpclient/http.rb', line 632 def parts if @as_stream @body else [@body.join] end end |