我有这个:
require 'yaml'
input = [
{
name: 'Maria Neusa de Aparecida',
cpf: '97905796671',
state: 'Sao Paulo',
value: '1234'
},
{
name: 'Ricardo Fontes',
cpf: '44010762900',
state: 'Rio Grande do Sul',
value: '567'
}
]
def solution(hash)
# some solution input + yaml config I guess
end
read = YAML.load_file('format-1.yaml')
puts read.inspect
在我的yaml文件中,我有:
cpf:
length: 11
align: left
padding: spaces
name:
length: 14
align: left
padding: spaces
value:
length: 8
align: right
padding: zeroes
如何将输出配置为如下所示:
"97905796671Maria Neusa de00001234\n44010762900Ricardo Fontes00000567"
到目前为止,我只能读取yaml文件,但我不知道如何继续…:(
目前,我的输出如下:
{"cpf"=>{"length"=>11, "align"=>"left", "padding"=>"spaces"}, "name"=>{"length"=>14, "align"=>"left", "padding"=>"spaces"}, "value"=>{"length"=>8, "align"=>"right", "padding"=>"zeroes"}}
暂无答案!
目前还没有任何答案,快来回答吧!