Sha256: e46c55ae228ebd09c22a0022842270dd190357b7acf1decad07f618294931fec
Contents?: true
Size: 725 Bytes
Versions: 9
Compression:
Stored size: 725 Bytes
Contents
# frozen_string_literal: true module Anyway module AutoCast # Regexp to detect array values # Array value is a values that contains at least one comma # and doesn't start/end with quote ARRAY_RXP = /\A[^'"].*\s*,\s*.*[^'"]\z/ def self.call(val) return val unless String === val case val when ARRAY_RXP val.split(/\s*,\s*/).map { call(_1) } when /\A(true|t|yes|y)\z/i true when /\A(false|f|no|n)\z/i false when /\A(nil|null)\z/i nil when /\A\d+\z/ val.to_i when /\A\d*\.\d+\z/ val.to_f when /\A['"].*['"]\z/ val.gsub(/(\A['"]|['"]\z)/, "") else val end end end end
Version data entries
9 entries across 9 versions & 1 rubygems