Class: Nugrant::Helper::Yaml

Inherits:
Object
  • Object
show all
Defined in:
lib/nugrant/helper/yaml.rb

Class Method Summary collapse

Class Method Details

.format(string, options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/nugrant/helper/yaml.rb', line 4

def self.format(string, options = {})
  lines =  string.send(string.respond_to?(:lines) ? :lines : :to_s).to_a
  lines = lines.drop(1)

  if options[:indent]
    indent_text = " " * options[:indent]
    lines = lines.map do |line|
      indent_text + line
    end
  end

  return lines.join("")
end