Sha256: 5c3a8ca3366f3f2b8683c8fda266875b79272210f0bc52a28406b687b9279431
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true module Anyway module Ext # Extend String through refinements module String refine ::String do # 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/ # rubocop:disable Metrics/MethodLength # rubocop:disable Metrics/CyclomaticComplexity def serialize case self when ARRAY_RXP # rubocop:disable Style/SymbolProc split(/\s*,\s*/).map { |word| word.serialize } # rubocop:enable Style/SymbolProc 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/ to_i when /\A\d*\.\d+\z/ to_f when /\A['"].*['"]\z/ gsub(/(\A['"]|['"]\z)/, '') else self end end # rubocop:enable Metrics/MethodLength # rubocop:enable Metrics/CyclomaticComplexity end using self end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
anyway_config-1.4.0 | lib/anyway/ext/string.rb |