Class: Infrastructure::Formatters::YAML

Inherits:
Base
  • Object
show all
Defined in:
lib/infrastructure/formatters/yaml.rb

Overview

transform hashes to YAML

Instance Method Summary collapse

Methods inherited from Base

format

Instance Method Details

#format(hash) ⇒ String

Parameters:

  • hash (Hash)

Returns:

  • (String)


12
13
14
# File 'lib/infrastructure/formatters/yaml.rb', line 12

def format(hash)
  "---\n#{hash.map { |k, v| "#{k}: '#{v.gsub(/['\n]/, "'" => "''", "\n" => '\\n')}'" }.join("\n")}\n"
end