require_relative '../../../../../gen/Design.ORiN3.Common/V1/orin3_common_pb' require_relative '../../../../../gen/Message.ORiN3.Provider/V1/orin3_variable_pb' require_relative '../../../../../gen/Message.ORiN3.Provider/V1/orin3_variable_services_pb' require_relative '../../../../../gen/Message.ORiN3.Provider/V1/orin3_common_type_pb' require_relative '../message_client_error' require_relative 'orin3_base_object' require_relative '../../../../grpc/orin3/provider/orin3_binary_converter' module O3P include Message::ORiN3::Provider::V1::AutoGenerated end module O3 include Design::ORiN3::Common::V1::AutoGenerated include Message::ORiN3::Provider::V1::AutoGenerated::Variable end module Grpc module Client module ORiN3 module Provider class ORiN3Variable < ORiN3BaseObject attr_reader :created_datetime, :value_type def initialize(channel, internal_id, created_datetime, value_type) @created_datetime = created_datetime @value_type = value_type super(channel, internal_id) end 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 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 private def check_integer(value, nullable, min, max) if !nullable && value.nil? raise ArgumentError, "Value is nil." elsif !value.nil? if !value.is_a?(Integer) raise ArgumentError, "Value is not Integer." elsif value < min || max < value raise ArgumentError, "Value #{value} is out of range. It must be between #{min} and #{max}." end end end def check_array_integer(value, nullable, min, max) 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 !nullable && item.nil? raise ArgumentError, "Value contains nil." elsif !item.nil? if !item.is_a?(Integer) raise ArgumentError, "Value is not Integer." elsif item < min || max < item raise ArgumentError, "Value #{item} is out of range. It must be between #{min} and #{max}." end end end end end end end end end