Class: Porkadot::Assets::ErbUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/porkadot/assets.rb

Instance Method Summary collapse

Instance Method Details

#indent(text, space = 2) ⇒ Object



3
4
5
6
# File 'lib/porkadot/assets.rb', line 3

def indent(text, space=2)
  space = space.times.map{' '}.join('')
  text.lines.map{|line| "#{space}#{line}"}.join('')
end

#to_yaml(obj, space = 0) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/porkadot/assets.rb', line 8

def to_yaml(obj, space=0)
  h = Hashie::Mash.new({obj: obj})
  h = h.to_hash
  if h['obj'].size == 0
    return ''
  end
  return self.indent(h['obj'].to_yaml(canonical: false, header: false).gsub(/---\n/, ''), space)
end