ruby YAML.load 和YAML.load_file区别
1.
load( io )
Load a document from the current io stream.
File.open( 'animals.yaml' ) { |yf| YAML::load( yf ) } #=> ['badger', 'elephant', 'tiger']
example:
require 'yaml'
yml = YAML::load(File.open('t.yml'))
p yml
Can also load from a string.
YAML.load( "--- :locked" ) #=> :locked
2.
load_file( filepath )
Load a document from the file located at filepath.
YAML.load_file( 'animals.yaml' ) #=> ['badger', 'elephant', 'tiger']
参考链接:http://www.ruby-doc.org/stdlib-1.8.7/libdoc/yaml/rdoc/YAML.html