Sha256: a662eb95571fb3e8aa979f95e1e8e8cfcfd8067be672d802fa2967653f6f62b0
Contents?: true
Size: 738 Bytes
Versions: 1
Compression:
Stored size: 738 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 def self.pluralization?(object) return false if object.nil? keys = object.keys.map { |k| k.to_sym } (keys.include? :one) and (keys.include? :other) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yaml-validator-0.1.2 | lib/helpers.rb |