输入可变参数名称后,匹配 name,匹配成功后从数组里面取出 hash 元素组成新的数组,现在匹配出现问题,始终匹配不上,英文没有问题,中文有问题
def index(*name)
index_array = [
{
"id"=>"C880680001",
"name"=>"CPU使用率(百分比)".,
"nodeType"=>40,
"dataType"=>"2"
},
{
"id"=>"C880680002",
"name"=>"CPU空闲率(百分比)",
"nodeType"=>40,
"dataType"=>"2"
},
{
"id"=>"C880680003",
"name"=>"CPU运行队列中进程个数",
"nodeType"=>40,
"dataType"=>"1"
},
{
"id"=>"C880680004",
"name"=>"CPU系统任务使用率(百分比)",
"nodeType"=>40,
"dataType"=>"2"
},
{
"id"=>"C880680005",
"name"=>"CPU用户任务使用率(百分比)",
"nodeType"=>40,
"dataType"=>"2"
},
{
"id"=>"C880680006",
"name"=>"CPU等待率(百分比)",
"nodeType"=>40,
"dataType"=>"2"
},
{
"id"=>"it.server.klinux.3135",
"name"=>"CPU使用率(百分比)",
"nodeType"=>20,
"dataType"=>"2"
}
]
index_new = []
for name_item in name
for index_array_item in index_array
index.push(index_array_item) if index_array_item["name"] == name_item
end
end
return index_new
end
data=[
{
"index"=>index("CPU使用率(百分比)","CPU等待率(百分比)"),
}
]
puts data