module Aio::Base::Toolkit::Hash
将嵌套的Hash变成二元数组
Constants
- StringConcat
建立一个结构体,方便包含cm的类型进行比较
Public Class Methods
flat(cm, chain, res, cm_type)
click to toggle source
返回的是以StringConcat为元素的数组
# File lib/aio/base/toolkit/hash.rb, line 44 def self.flat(cm, chain, res, cm_type) cm.each_pair do |key, val| if val.kind_of? ::Hash chain.split(key, val.size) Aio::Base::Toolkit::Hash.flat(val, chain, res, cm_type) else last_chain = chain.get_line unless chain.empty? last_chain ||= [] last_chain.push(key.to_s) last_chain.push(val) res << StringConcat.new(last_chain, cm_type) end end end
flat_cm1(cm, chain, res)
click to toggle source
# File lib/aio/base/toolkit/hash.rb, line 35 def self.flat_cm1(cm, chain, res) Hash.flat(cm, chain, res, :cm1) end
flat_cm2(cm, chain, res)
click to toggle source
# File lib/aio/base/toolkit/hash.rb, line 39 def self.flat_cm2(cm, chain, res) Hash.flat(cm, chain, res, :cm2) end