Class: Grpc::Client::ORiN3::Provider::ORiN3Variable
- Inherits:
-
ORiN3BaseObject
- Object
- ORiN3BaseObject
- Grpc::Client::ORiN3::Provider::ORiN3Variable
- Defined in:
- lib/grpc/client/orin3/provider/orin3_variable.rb
Instance Attribute Summary collapse
-
#created_datetime ⇒ Object
readonly
Returns the value of attribute created_datetime.
-
#value_type ⇒ Object
readonly
Returns the value of attribute value_type.
Attributes inherited from ORiN3BaseObject
#name, #option, #orin3_object_type, #type_name
Instance Method Summary collapse
- #get_value ⇒ Object
-
#initialize(channel, internal_id, created_datetime, value_type) ⇒ ORiN3Variable
constructor
A new instance of ORiN3Variable.
- #set_value(value) ⇒ Object
Methods inherited from ORiN3BaseObject
#execute, #get_status, #get_tag, #get_tag_keys, #id, #remove_tag, #set_tag
Constructor Details
#initialize(channel, internal_id, created_datetime, value_type) ⇒ ORiN3Variable
Returns a new instance of ORiN3Variable.
25 26 27 28 29 |
# File 'lib/grpc/client/orin3/provider/orin3_variable.rb', line 25 def initialize(channel, internal_id, created_datetime, value_type) @created_datetime = created_datetime @value_type = value_type super(channel, internal_id) end |
Instance Attribute Details
#created_datetime ⇒ Object (readonly)
Returns the value of attribute created_datetime.
23 24 25 |
# File 'lib/grpc/client/orin3/provider/orin3_variable.rb', line 23 def created_datetime @created_datetime end |
#value_type ⇒ Object (readonly)
Returns the value of attribute value_type.
23 24 25 |
# File 'lib/grpc/client/orin3/provider/orin3_variable.rb', line 23 def value_type @value_type end |
Instance Method Details
#get_value ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/grpc/client/orin3/provider/orin3_variable.rb', line 31 def get_value begin variable = O3::VariableService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel) request = O3::GetValueRequest.new(common: O3P::CommonRequest.new, id: @internal_id, value_type: @value_type) response = variable.get_value(request) if (response.common.result_code != :SUCCEEDED) raise MessageClientError.new(response.common.result_code, response.common.detail) end case @value_type # BOOL when :ORIN3_BOOL return response.value.bool.raw_value when :ORIN3_BOOL_ARRAY return response.value.bool_array.raw_value.map { |it| it } when :ORIN3_NULLABLE_BOOL return response.value.nullable_bool.is_null == true ? nil : response.value.nullable_bool.raw_value when :ORIN3_NULLABLE_BOOL_ARRAY return response.value.nullable_bool_array.raw_value.map { |it| it.is_null == true ? nil : it.raw_value } # UINT8 when :ORIN3_UINT8 return response.value.uint8.raw_value when :ORIN3_NULLABLE_UINT8 return response.value.nullable_uint8.is_null == true ? nil : response.value.nullable_uint8.raw_value when :ORIN3_UINT8_ARRAY return response.value.uint8_array.raw_value.map { |it| it } when :ORIN3_NULLABLE_UINT8_ARRAY return response.value.nullable_uint8_array.raw_value.map { |it| it.is_null == true ? nil : it.raw_value } # UINT16 when :ORIN3_UINT16 return response.value.uint16.raw_value when :ORIN3_NULLABLE_UINT16 return response.value.nullable_uint16.is_null == true ? nil : response.value.nullable_uint16.raw_value when :ORIN3_UINT16_ARRAY return response.value.uint16_array.raw_value.map { |it| it } when :ORIN3_NULLABLE_UINT16_ARRAY return response.value.nullable_uint16_array.raw_value.map { |it| it.is_null == true ? nil : it.raw_value } # UINT32 when :ORIN3_UINT32 return response.value.uint32.raw_value when :ORIN3_NULLABLE_UINT32 return response.value.nullable_uint32.is_null == true ? nil : response.value.nullable_uint32.raw_value when :ORIN3_UINT32_ARRAY return response.value.uint32_array.raw_value.map { |it| it } when :ORIN3_NULLABLE_UINT32_ARRAY return response.value.nullable_uint32_array.raw_value.map { |it| it.is_null == true ? nil : it.raw_value } # UINT64 when :ORIN3_UINT64 return response.value.uint64.raw_value when :ORIN3_NULLABLE_UINT64 return response.value.nullable_uint64.is_null == true ? nil : response.value.nullable_uint64.raw_value when :ORIN3_UINT64_ARRAY return response.value.uint64_array.raw_value.map { |it| it } when :ORIN3_NULLABLE_UINT64_ARRAY return response.value.nullable_uint64_array.raw_value.map { |it| it.is_null == true ? nil : it.raw_value } # INT8 when :ORIN3_INT8 return response.value.int8.raw_value when :ORIN3_NULLABLE_INT8 return response.value.nullable_int8.is_null == true ? nil : response.value.nullable_int8.raw_value when :ORIN3_INT8_ARRAY return response.value.int8_array.raw_value.map { |it| it } when :ORIN3_NULLABLE_INT8_ARRAY return response.value.nullable_int8_array.raw_value.map { |it| it.is_null == true ? nil : it.raw_value } # INT16 when :ORIN3_INT16 return response.value.int16.raw_value when :ORIN3_NULLABLE_INT16 return response.value.nullable_int16.is_null == true ? nil : response.value.nullable_int16.raw_value when :ORIN3_INT16_ARRAY return response.value.int16_array.raw_value.map { |it| it } when :ORIN3_NULLABLE_INT16_ARRAY return response.value.nullable_int16_array.raw_value.map { |it| it.is_null == true ? nil : it.raw_value } # INT32 when :ORIN3_INT32 return response.value.int32.raw_value when :ORIN3_NULLABLE_INT32 return response.value.nullable_int32.is_null == true ? nil : response.value.nullable_int32.raw_value when :ORIN3_INT32_ARRAY return response.value.int32_array.raw_value.map { |it| it } when :ORIN3_NULLABLE_INT32_ARRAY return response.value.nullable_int32_array.raw_value.map { |it| it.is_null == true ? nil : it.raw_value } # INT64 when :ORIN3_INT64 return response.value.int64.raw_value when :ORIN3_NULLABLE_INT64 return response.value.nullable_int64.is_null == true ? nil : response.value.nullable_int64.raw_value when :ORIN3_INT64_ARRAY return response.value.int64_array.raw_value.map { |it| it } when :ORIN3_NULLABLE_INT64_ARRAY return response.value.nullable_int64_array.raw_value.map { |it| it.is_null == true ? nil : it.raw_value } # FLOAT when :ORIN3_FLOAT return response.value.float.raw_value when :ORIN3_NULLABLE_FLOAT return response.value.nullable_float.is_null == true ? nil : response.value.nullable_float.raw_value when :ORIN3_FLOAT_ARRAY return response.value.float_array.raw_value.map { |it| it } when :ORIN3_NULLABLE_FLOAT_ARRAY return response.value.nullable_float_array.raw_value.map { |it| it.is_null == true ? nil : it.raw_value } # DOUBLE when :ORIN3_DOUBLE return response.value.double.raw_value when :ORIN3_NULLABLE_DOUBLE return response.value.nullable_double.is_null == true ? nil : response.value.nullable_double.raw_value when :ORIN3_DOUBLE_ARRAY return response.value.double_array.raw_value.map { |it| it } when :ORIN3_NULLABLE_DOUBLE_ARRAY return response.value.nullable_double_array.raw_value.map { |it| it.is_null == true ? nil : it.raw_value } # DATETIME when :ORIN3_DATETIME return Grpc::ORiN3::Provider::DateTimeConverter.from_int64(response.value.datetime.raw_value) when :ORIN3_NULLABLE_DATETIME return response.value.nullable_datetime.is_null == true ? nil : Grpc::ORiN3::Provider::DateTimeConverter.from_int64(response.value.nullable_datetime.raw_value) when :ORIN3_DATETIME_ARRAY return response.value.datetime_array.raw_value.map { |it| Grpc::ORiN3::Provider::DateTimeConverter.from_int64(it) } when :ORIN3_NULLABLE_DATETIME_ARRAY return response.value.nullable_datetime_array.raw_value.map { |it| it.is_null == true ? nil : Grpc::ORiN3::Provider::DateTimeConverter.from_int64(it.raw_value) } # STRING when :ORIN3_STRING if response.value.string.is_null return nil else return response.value.string.raw_value end when :ORIN3_STRING_ARRAY return response.value.string_array.raw_value.map { |it| it.is_null ? nil : it.raw_value } else return ORiN3BinaryConverter.deserialize(response.value.int32.raw_value) end rescue MessageClientError raise rescue StandardError => e raise MessageClientError.new(e) end end |
#set_value(value) ⇒ Object
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 |
# File 'lib/grpc/client/orin3/provider/orin3_variable.rb', line 167 def set_value(value) begin orin3_value = O3P::ORiN3Value.new(type: @value_type) case @value_type # BOOL when :ORIN3_BOOL if value.nil? raise ArgumentError, "Value is nil." elsif !value.is_a?(TrueClass) && !value.is_a?(FalseClass) raise ArgumentError, "Value is not Boolean." end orin3_value.bool = O3P::ORiN3Bool.new(raw_value: value) when :ORIN3_BOOL_ARRAY if value.nil? raise ArgumentError, "Value is nil." elsif !value.is_a?(Array) raise ArgumentError, "Value is not Array." end value.each do |item| if item.nil? raise ArgumentError, "Value contains nil." elsif !item.is_a?(TrueClass) && !item.is_a?(FalseClass) raise ArgumentError, "Value is not Integer." end end orin3_value.bool_array = O3P::ORiN3BoolArray.new(raw_value: value) when :ORIN3_NULLABLE_BOOL if !value.nil? && !value.is_a?(TrueClass) && !value.is_a?(FalseClass) raise ArgumentError, "Value is not Boolean." end orin3_value.nullable_bool = O3P::ORiN3NullableBool.new(is_null: value.nil?, raw_value: value) when :ORIN3_NULLABLE_BOOL_ARRAY if value.nil? raise ArgumentError, "Value is nil." elsif !value.is_a?(Array) raise ArgumentError, "Value is not Array." end value.each do |item| if !item.nil? && !item.is_a?(TrueClass) && !item.is_a?(FalseClass) raise ArgumentError, "Value is not Boolean." end end orin3_value.nullable_bool_array = O3P::ORiN3NullableBoolArray.new(raw_value: value.map { |it| O3P::ORiN3NullableBool.new(is_null: it.nil?, raw_value: it) }) # UINT8 when :ORIN3_UINT8 check_integer(value, false, ORiN3BinaryConverter::UINT8_MIN, ORiN3BinaryConverter::UINT8_MAX) orin3_value.uint8 = O3P::ORiN3UInt8.new(raw_value: value) when :ORIN3_UINT8_ARRAY check_array_integer(value, false, ORiN3BinaryConverter::UINT8_MIN, ORiN3BinaryConverter::UINT8_MAX) orin3_value.uint8_array = O3P::ORiN3UInt8Array.new(raw_value: value) when :ORIN3_NULLABLE_UINT8 check_integer(value, true, ORiN3BinaryConverter::UINT8_MIN, ORiN3BinaryConverter::UINT8_MAX) orin3_value.nullable_uint8 = O3P::ORiN3NullableUInt8.new(is_null: value.nil?, raw_value: value) when :ORIN3_NULLABLE_UINT8_ARRAY check_array_integer(value, true, ORiN3BinaryConverter::UINT8_MIN, ORiN3BinaryConverter::UINT8_MAX) orin3_value.nullable_uint8_array = O3P::ORiN3NullableUInt8Array.new(raw_value: value.map { |it| O3P::ORiN3NullableUInt8.new(is_null: it.nil?, raw_value: it) }) # UINT16 when :ORIN3_UINT16 check_integer(value, false, ORiN3BinaryConverter::UINT16_MIN, ORiN3BinaryConverter::UINT16_MAX) orin3_value.uint16 = O3P::ORiN3UInt16.new(raw_value: value) when :ORIN3_UINT16_ARRAY check_array_integer(value, false, ORiN3BinaryConverter::UINT16_MIN, ORiN3BinaryConverter::UINT16_MAX) orin3_value.uint16_array = O3P::ORiN3UInt16Array.new(raw_value: value) when :ORIN3_NULLABLE_UINT16 check_integer(value, true, ORiN3BinaryConverter::UINT16_MIN, ORiN3BinaryConverter::UINT16_MAX) orin3_value.nullable_uint16 = O3P::ORiN3NullableUInt16.new(is_null: value.nil?, raw_value: value) when :ORIN3_NULLABLE_UINT16_ARRAY check_array_integer(value, true, ORiN3BinaryConverter::UINT16_MIN, ORiN3BinaryConverter::UINT16_MAX) orin3_value.nullable_uint16_array = O3P::ORiN3NullableUInt16Array.new(raw_value: value.map { |it| O3P::ORiN3NullableUInt16.new(is_null: it.nil?, raw_value: it) }) # UINT32 when :ORIN3_UINT32 check_integer(value, false, ORiN3BinaryConverter::UINT32_MIN, ORiN3BinaryConverter::UINT32_MAX) orin3_value.uint32 = O3P::ORiN3UInt32.new(raw_value: value) when :ORIN3_UINT32_ARRAY check_array_integer(value, false, ORiN3BinaryConverter::UINT32_MIN, ORiN3BinaryConverter::UINT32_MAX) orin3_value.uint32_array = O3P::ORiN3UInt32Array.new(raw_value: value) when :ORIN3_NULLABLE_UINT32 check_integer(value, true, ORiN3BinaryConverter::UINT32_MIN, ORiN3BinaryConverter::UINT32_MAX) orin3_value.nullable_uint32 = O3P::ORiN3NullableUInt32.new(is_null: value.nil?, raw_value: value) when :ORIN3_NULLABLE_UINT32_ARRAY check_array_integer(value, true, ORiN3BinaryConverter::UINT32_MIN, ORiN3BinaryConverter::UINT32_MAX) orin3_value.nullable_uint32_array = O3P::ORiN3NullableUInt32Array.new(raw_value: value.map { |it| O3P::ORiN3NullableUInt32.new(is_null: it.nil?, raw_value: it) }) # UINT64 when :ORIN3_UINT64 check_integer(value, false, ORiN3BinaryConverter::UINT64_MIN, ORiN3BinaryConverter::UINT64_MAX) orin3_value.uint64 = O3P::ORiN3UInt64.new(raw_value: value) when :ORIN3_UINT64_ARRAY check_array_integer(value, false, ORiN3BinaryConverter::UINT64_MIN, ORiN3BinaryConverter::UINT64_MAX) orin3_value.uint64_array = O3P::ORiN3UInt64Array.new(raw_value: value) when :ORIN3_NULLABLE_UINT64 check_integer(value, true, ORiN3BinaryConverter::UINT64_MIN, ORiN3BinaryConverter::UINT64_MAX) orin3_value.nullable_uint64 = O3P::ORiN3NullableUInt64.new(is_null: value.nil?, raw_value: value) when :ORIN3_NULLABLE_UINT64_ARRAY check_array_integer(value, true, ORiN3BinaryConverter::UINT64_MIN, ORiN3BinaryConverter::UINT64_MAX) orin3_value.nullable_uint64_array = O3P::ORiN3NullableUInt64Array.new(raw_value: value.map { |it| O3P::ORiN3NullableUInt64.new(is_null: it.nil?, raw_value: it) }) # INT8 when :ORIN3_INT8 check_integer(value, false, ORiN3BinaryConverter::INT8_MIN, ORiN3BinaryConverter::INT8_MAX) orin3_value.int8 = O3P::ORiN3Int8.new(raw_value: value) when :ORIN3_INT8_ARRAY check_array_integer(value, false, ORiN3BinaryConverter::INT8_MIN, ORiN3BinaryConverter::INT8_MAX) orin3_value.int8_array = O3P::ORiN3Int8Array.new(raw_value: value) when :ORIN3_NULLABLE_INT8 check_integer(value, true, ORiN3BinaryConverter::INT8_MIN, ORiN3BinaryConverter::INT8_MAX) orin3_value.nullable_int8 = O3P::ORiN3NullableInt8.new(is_null: value.nil?, raw_value: value) when :ORIN3_NULLABLE_INT8_ARRAY check_array_integer(value, true, ORiN3BinaryConverter::INT8_MIN, ORiN3BinaryConverter::INT8_MAX) orin3_value.nullable_int8_array = O3P::ORiN3NullableInt8Array.new(raw_value: value.map { |it| O3P::ORiN3NullableInt8.new(is_null: it.nil?, raw_value: it) }) # INT16 when :ORIN3_INT16 check_integer(value, false, ORiN3BinaryConverter::INT16_MIN, ORiN3BinaryConverter::INT16_MAX) orin3_value.int16 = O3P::ORiN3Int16.new(raw_value: value) when :ORIN3_INT16_ARRAY check_array_integer(value, false, ORiN3BinaryConverter::INT16_MIN, ORiN3BinaryConverter::INT16_MAX) orin3_value.int16_array = O3P::ORiN3Int16Array.new(raw_value: value) when :ORIN3_NULLABLE_INT16 check_integer(value, true, ORiN3BinaryConverter::INT16_MIN, ORiN3BinaryConverter::INT16_MAX) orin3_value.nullable_int16 = O3P::ORiN3NullableInt16.new(is_null: value.nil?, raw_value: value) when :ORIN3_NULLABLE_INT16_ARRAY check_array_integer(value, true, ORiN3BinaryConverter::INT16_MIN, ORiN3BinaryConverter::INT16_MAX) orin3_value.nullable_int16_array = O3P::ORiN3NullableInt16Array.new(raw_value: value.map { |it| O3P::ORiN3NullableInt16.new(is_null: it.nil?, raw_value: it) }) # INT32 when :ORIN3_INT32 check_integer(value, false, ORiN3BinaryConverter::INT32_MIN, ORiN3BinaryConverter::INT32_MAX) orin3_value.int32 = O3P::ORiN3Int32.new(raw_value: value) when :ORIN3_INT32_ARRAY check_array_integer(value, false, ORiN3BinaryConverter::INT32_MIN, ORiN3BinaryConverter::INT32_MAX) orin3_value.int32_array = O3P::ORiN3Int32Array.new(raw_value: value) when :ORIN3_NULLABLE_INT32 check_integer(value, true, ORiN3BinaryConverter::INT32_MIN, ORiN3BinaryConverter::INT32_MAX) orin3_value.nullable_int32 = O3P::ORiN3NullableInt32.new(is_null: value.nil?, raw_value: value) when :ORIN3_NULLABLE_INT32_ARRAY check_array_integer(value, true, ORiN3BinaryConverter::INT32_MIN, ORiN3BinaryConverter::INT32_MAX) orin3_value.nullable_int32_array = O3P::ORiN3NullableInt32Array.new(raw_value: value.map { |it| O3P::ORiN3NullableInt32.new(is_null: it.nil?, raw_value: it) }) # INT64 when :ORIN3_INT64 check_integer(value, false, ORiN3BinaryConverter::INT64_MIN, ORiN3BinaryConverter::INT64_MAX) orin3_value.int64 = O3P::ORiN3Int64.new(raw_value: value) when :ORIN3_INT64_ARRAY check_array_integer(value, false, ORiN3BinaryConverter::INT64_MIN, ORiN3BinaryConverter::INT64_MAX) orin3_value.int64_array = O3P::ORiN3Int64Array.new(raw_value: value) when :ORIN3_NULLABLE_INT64 check_integer(value, true, ORiN3BinaryConverter::INT64_MIN, ORiN3BinaryConverter::INT64_MAX) orin3_value.nullable_int64 = O3P::ORiN3NullableInt64.new(is_null: value.nil?, raw_value: value) when :ORIN3_NULLABLE_INT64_ARRAY check_array_integer(value, true, ORiN3BinaryConverter::INT64_MIN, ORiN3BinaryConverter::INT64_MAX) orin3_value.nullable_int64_array = O3P::ORiN3NullableInt64Array.new(raw_value: value.map { |it| O3P::ORiN3NullableInt64.new(is_null: it.nil?, raw_value: it) }) # FLOAT when :ORIN3_FLOAT if value.nil? raise ArgumentError, "Value is nil." elsif !value.is_a?(Float) raise ArgumentError, "Value is not Float." end orin3_value.float = O3P::ORiN3Float.new(raw_value: value) when :ORIN3_FLOAT_ARRAY if value.nil? raise ArgumentError, "Value is nil." elsif !value.is_a?(Array) raise ArgumentError, "Value is not Array." end value.each do |item| if item.nil? raise ArgumentError, "Value contains nil." elsif !item.is_a?(Float) raise ArgumentError, "Value is not Float." end end orin3_value.float_array = O3P::ORiN3FloatArray.new(raw_value: value) when :ORIN3_NULLABLE_FLOAT if !value.nil? && !value.is_a?(Float) raise ArgumentError, "Value is not Float." end orin3_value.nullable_float = O3P::ORiN3NullableFloat.new(is_null: value.nil?, raw_value: value) when :ORIN3_NULLABLE_FLOAT_ARRAY if value.nil? raise ArgumentError, "Value is nil." elsif !value.is_a?(Array) raise ArgumentError, "Value is not Array." end value.each do |item| if !item.nil? && !item.is_a?(Float) raise ArgumentError, "Value is not Float." end end orin3_value.nullable_float_array = O3P::ORiN3NullableFloatArray.new(raw_value: value.map { |it| O3P::ORiN3NullableFloat.new(is_null: it.nil?, raw_value: it) }) # DOUBLE when :ORIN3_DOUBLE if value.nil? raise ArgumentError, "Value is nil." elsif !value.is_a?(Float) raise ArgumentError, "Value is not Float." end orin3_value.double = O3P::ORiN3Double.new(raw_value: value) when :ORIN3_DOUBLE_ARRAY if value.nil? raise ArgumentError, "Value is nil." elsif !value.is_a?(Array) raise ArgumentError, "Value is not Array." end value.each do |item| if item.nil? raise ArgumentError, "Value contains nil." elsif !item.is_a?(Float) raise ArgumentError, "Value is not Float." end end orin3_value.double_array = O3P::ORiN3DoubleArray.new(raw_value: value) when :ORIN3_NULLABLE_DOUBLE if !value.nil? && !value.is_a?(Float) raise ArgumentError, "Value is not Float." end orin3_value.nullable_double = O3P::ORiN3NullableDouble.new(is_null: value.nil?, raw_value: value) when :ORIN3_NULLABLE_DOUBLE_ARRAY if value.nil? raise ArgumentError, "Value is nil." elsif !value.is_a?(Array) raise ArgumentError, "Value is not Array." end value.each do |item| if !item.nil? && !item.is_a?(Float) raise ArgumentError, "Value is not Float." end end orin3_value.nullable_double_array = O3P::ORiN3NullableDoubleArray.new(raw_value: value.map { |it| O3P::ORiN3NullableDouble.new(is_null: it.nil?, raw_value: it) }) # DATETIME when :ORIN3_DATETIME if value.nil? raise ArgumentError, "Value is nil." elsif !value.is_a?(Time) raise ArgumentError, "Value is not Time." end orin3_value.datetime = O3P::ORiN3DateTime.new(raw_value: Grpc::ORiN3::Provider::DateTimeConverter.to_int64(value)) when :ORIN3_DATETIME_ARRAY if value.nil? raise ArgumentError, "Value is nil." elsif !value.is_a?(Array) raise ArgumentError, "Value is not Array." end value.each do |item| if item.nil? raise ArgumentError, "Value contains nil." elsif !item.is_a?(Time) raise ArgumentError, "Value is not Time." end end orin3_value.datetime_array = O3P::ORiN3DateTimeArray.new(raw_value: value.map { |it| Grpc::ORiN3::Provider::DateTimeConverter.to_int64(it) }) when :ORIN3_NULLABLE_DATETIME if !value.nil? && !value.is_a?(Time) raise ArgumentError, "Value is not Time." end orin3_value.nullable_datetime = O3P::ORiN3NullableDateTime.new(is_null: value.nil?, raw_value: value.nil? ? nil : Grpc::ORiN3::Provider::DateTimeConverter.to_int64(value)) when :ORIN3_NULLABLE_DATETIME_ARRAY if value.nil? raise ArgumentError, "Value is nil." elsif !value.is_a?(Array) raise ArgumentError, "Value is not Array." end value.each do |item| if !item.nil? && !item.is_a?(Time) raise ArgumentError, "Value is not Time." end end orin3_value.nullable_datetime_array = O3P::ORiN3NullableDateTimeArray.new(raw_value: value.map { |it| O3P::ORiN3NullableDateTime.new(is_null: it.nil?, raw_value: it.nil? ? nil : Grpc::ORiN3::Provider::DateTimeConverter.to_int64(it)) }) # STRING when :ORIN3_STRING if !value.nil? && !value.is_a?(String) raise ArgumentError, "Value is not String." end orin3_value.string = O3P::ORiN3String.new(is_null: value.nil?, raw_value: value) when :ORIN3_STRING_ARRAY if value.nil? raise ArgumentError, "Value is nil." elsif !value.is_a?(Array) raise ArgumentError, "Value is not Array." end value.each do |item| if !item.nil? && !item.is_a?(String) raise ArgumentError, "Value is not String." end end orin3_value.string_array = O3P::ORiN3StringArray.new(raw_value: value.map { |it| O3P::ORiN3String.new(is_null: it.nil?, raw_value: it) }) else raise ArgumentError.new("Not supported.") end variable = O3::VariableService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel) request = O3::SetValueRequest.new(common: O3P::CommonRequest.new, id: @internal_id, value: orin3_value) response = variable.set_value(request) if (response.common.result_code != :SUCCEEDED) raise MessageClientError.new(response.common.result_code, response.common.detail) end rescue MessageClientError raise rescue StandardError => e raise MessageClientError.new(e) end end |