Class: UU::OS::REST::BinaryValue
- Inherits:
-
DTO
- Object
- DTO
- UU::OS::REST::BinaryValue
- Defined in:
- uu_os_framework-0.29.16/lib/uu/os/rest/binary_value.rb
Overview
Binary data wrapper used for uploading small data to server and handling binary data response.
Direct Known Subclasses
Instance Attribute Summary (collapse)
-
- (String) content_type
Data content type.
-
- (IO) data
Data payload.
-
- (String) encoding
Data encoding (used for text-based content types).
-
- (String) name
Data name.
-
- (Numeric) size
Data size.
Instance Method Summary (collapse)
-
- (BinaryValue) initialize(init_data = nil, init_as_retval = false)
constructor
Creates new instance of BinaryValue.
Methods inherited from DTO
Constructor Details
- (BinaryValue) initialize(init_data = nil, init_as_retval = false)
Creates new instance of BinaryValue.
63 64 65 66 67 68 69 70 71 72 |
# File 'uu_os_framework-0.29.16/lib/uu/os/rest/binary_value.rb', line 63 def initialize(init_data = nil, init_as_retval = false) @serialize_as_stream_handler = true @init_as_retval = init_as_retval if (@init_as_retval) || (!init_data.kind_of?String) super(init_data) else super(nil) self.data = init_data end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class UU::OS::REST::DTO
Instance Attribute Details
- (String) content_type
Data content type. If not set, value will be determined from given data source or default application/octet-stream will be used for uploading. In case of download, value might be empty (depends on server providing necessary data).
40 41 42 |
# File 'uu_os_framework-0.29.16/lib/uu/os/rest/binary_value.rb', line 40 def content_type @content_type end |
- (IO) data
Data payload. Setter accepts values of type File
,
Tempfile
, IO
, StringIO
or
String
. Getter always returns "IO" object - something which
responds to "read" method. Be careful, reading of raw binary data does not
implicitly handle encoding. Result might need to be explicitly converted
using "force_encoding" method.
18 19 20 |
# File 'uu_os_framework-0.29.16/lib/uu/os/rest/binary_value.rb', line 18 def data @data end |
- (String) encoding
Data encoding (used for text-based content types). If not set, value will be determined from given data source or default system value will be used for uploading. In case of download, value might be empty (depends on server providing necessary data).
48 49 50 |
# File 'uu_os_framework-0.29.16/lib/uu/os/rest/binary_value.rb', line 48 def encoding @encoding end |
- (String) name
Data name. If not set and given data is instance of File, file base name will be used by default for uploading. In case of download, value might be empty (depends on server providing necessary data).
32 33 34 |
# File 'uu_os_framework-0.29.16/lib/uu/os/rest/binary_value.rb', line 32 def name @name end |
- (Numeric) size
Data size. If not set, value will be computed from given data object for uploading. In case of download, value might be empty (depends on server providing necessary data).
25 26 27 |
# File 'uu_os_framework-0.29.16/lib/uu/os/rest/binary_value.rb', line 25 def size @size end |