Sha256: 38ec0c3bcfde0a6791cb26c0df83c6ee8aad51da7afd69b79877b88dc0c10ad1
Contents?: true
Size: 743 Bytes
Versions: 8
Compression:
Stored size: 743 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.to_s] = 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
8 entries across 8 versions & 1 rubygems