Class: Alf::Reader::YAML

Inherits:
Alf::Reader show all
Defined in:
lib/alf/reader/yaml.rb

Overview

Implements Alf::Reader contract for reading YAML input.

Constant Summary

Constants inherited from Alf::Reader

DEFAULT_OPTIONS

Instance Attribute Summary

Attributes inherited from Alf::Reader

#input, #options, #path

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Alf::Reader

by_mime_type, coerce, #initialize, reader, register, #to_s

Methods included from Support::Registry

#listen, #listeners, #register, #registered

Constructor Details

This class inherits a constructor from Alf::Reader

Class Method Details

.mime_typeObject


8
9
10
# File 'lib/alf/reader/yaml.rb', line 8

def self.mime_type
  "text/yaml"
end

Instance Method Details

#eachObject


12
13
14
15
16
17
18
19
20
# File 'lib/alf/reader/yaml.rb', line 12

def each
  return to_enum unless block_given?
  require 'yaml'
  p = ::YAML.load(input_text)
  p = [p] if TupleLike===p
  p.each do |t|
    yield Support.symbolize_keys(t)
  end
end