Skip to content

Instantly share code, notes, and snippets.

@note103
Created December 8, 2015 05:05
Show Gist options
  • Save note103/ecb79e2466ebfd48b93d to your computer and use it in GitHub Desktop.
Save note103/ecb79e2466ebfd48b93d to your computer and use it in GitHub Desktop.
yamlの練習
#!/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