Sha256: 0ef00b8241fc4e235ebb19b24432e2f2acac99b59af1d4abae8ff490127e7b69
Contents?: true
Size: 567 Bytes
Versions: 2
Compression:
Stored size: 567 Bytes
Contents
module Helpers def self.normalize_yaml(yaml) return '' if yaml.nil? return yaml if yaml.is_a? String return yaml.to_s if yaml.is_a? Numeric return yaml.to_s if !!yaml == yaml # if boolean return ":#{yaml.to_s}" if yaml.is_a? Symbol yaml = array_to_hash(yaml) if yaml.is_a? Array normalized = {} yaml.each do |key, value| normalized[key] = normalize_yaml(value) end normalized end def self.array_to_hash(array) hash = {} array.each_with_index { |val, i| hash[i.to_s] = val } hash end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
yaml-validator-0.1.1 | lib/helpers.rb |
yaml-validator-0.1.0 | lib/helpers.rb |