Sha256: 48337a72c489e01d89010d05a7ed149508a6c5d02cb54bc42cb7568f097c016c
Contents?: true
Size: 703 Bytes
Versions: 10
Compression:
Stored size: 703 Bytes
Contents
module CPEE class ValueHelper def self::generate(value) if [String, Integer, Float, TrueClass, FalseClass, Date].include? value.class value.to_s elsif [Hash, Array].include? value.class JSON::generate(value) elsif value.respond_to?(:to_s) value.to_s end end def self::parse(value) case value.downcase when 'true' true when 'false' false when 'nil', 'null' nil else begin JSON::parse(value) rescue (Integer value rescue nil) || (Float value rescue nil) || value.to_s rescue nil || '' end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems