Sha256: 0342a8d1d95d6cb62591062f4b10041b4223eb6eac1545f4f07859bb8ba52e67
Contents?: true
Size: 818 Bytes
Versions: 16
Compression:
Stored size: 818 Bytes
Contents
# frozen_string_literal: true require "service_skeleton/config_variable" class ServiceSkeleton::ConfigVariable::Float < ServiceSkeleton::ConfigVariable private def pluck_value(env) maybe_default(env) do value = env[@name.to_s] if value =~ /\A-?\d+.?\d*\z/ value.to_f.tap do |f| unless @opts[:range].include?(f) raise ServiceSkeleton::Error::InvalidEnvironmentError, "Value #{f} for environment variable #{@name} is out of the valid range (must be between #{@opts[:range].first} and #{@opts[:range].last} inclusive)" end end else raise ServiceSkeleton::Error::InvalidEnvironmentError, "Value #{value.inspect} for environment variable #{@name} is not a valid numeric value" end end end end
Version data entries
16 entries across 16 versions & 1 rubygems