Created
December 8, 2015 05:05
-
-
Save note103/ecb79e2466ebfd48b93d to your computer and use it in GitHub Desktop.
yamlの練習
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# http://magazine.rubyist.net/?0009-YAML | |
# | |
# 引数を使う場合 | |
#str = ARGF.read() # 入力をすべて読み込む | |
#data = YAML.load(str) # パースする | |
# | |
# コード上でファイルを指定する場合 | |
#data = YAML.load_file('data.yml') | |
# 定数DATAを使う場合 | |
# http://docs.ruby-lang.org/ja/2.2.0/class/Object.html#C_-D-A-T-A | |
require 'yaml' | |
require 'pp' | |
data = YAML.load(DATA) | |
pp data | |
__END__ | |
- aaa | |
- | |
- b1 | |
- b2 | |
- | |
- b3.1 | |
- b3.2 | |
- | |
- foo | |
- bar | |
- baz | |
- | |
- qux | |
- quux |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment