0Pricing
Ruby Academy · Lesson

YAML Configuration

Load and dump YAML.

What Is YAML?

YAML (YAML Ain't Markup Language) is a human-friendly data format widely used for configuration. Ruby reads it via the yaml library (built on Psych).

require 'yaml'
text = "name: Ruby\nyear: 1995"
p YAML.load(text)

Loading YAML

YAML.load parses a YAML string into Ruby objects. Mappings become Hashes, sequences become Arrays.

require 'yaml'
cfg = YAML.load("port: 8081\ndebug: true")
puts(cfg['port'])
puts(cfg['debug'])

All lessons in this course

  1. Reading and Writing JSON
  2. Working with CSV
  3. YAML Configuration
  4. Choosing a Format
← Back to Ruby Academy