Module: CLValueBytesParsers::CLTupleBytesParser
- Extended by:
- CLTupleBytesParser
- Included in:
- CLTuple, CLTupleBytesParser
- Defined in:
- lib/serialization/cl_value_bytes_parsers.rb
Instance Method Summary collapse
Instance Method Details
#from_bytes(types, byte_array) ⇒ Object
251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/serialization/cl_value_bytes_parsers.rb', line 251 def from_bytes(types, byte_array) size = types.size if size == 1 type = types[0] convert_from_bytes(type, byte_array) elsif size == 2 type_of_clvalue1 = types[0] type_of_clvalue2 = types[1] else raise "error" end end |
#to_bytes(tuple) ⇒ Object
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/serialization/cl_value_bytes_parsers.rb', line 228 def to_bytes(tuple) # tuple_name can be Tuple1 or Tuple2 or Tuple3 tuple_name = tuple.get_tuple_name size = tuple.get_size data = tuple.get_value if size == 1 type = data[0].get_cl_type value = data[0] convert_to_bytes(type, value) elsif size == 2 # puts data[0] # puts data[1] clvalue1 = data[0] type_of_clvalue1 = clvalue1.get_cl_type clvalue2 = data[1] type_of_clvalue2 = clvalue2.get_cl_type convert_to_bytes(type_of_clvalue1, clvalue1) + convert_to_bytes(type_of_clvalue2, clvalue2) # elsif size == 3 else raise "error" end end |