Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-nixos/nix.rb

Instance Method Summary collapse

Instance Method Details

#to_nix(indent = 0) ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'lib/vagrant-nixos/nix.rb', line 53

def to_nix(indent = 0)
	"{\n" +
	sort {|a, b| a[0].to_s <=> b[0].to_s}.map do |key, value|
		raise "Key must be a Symbol, not #{key.class}" unless key.is_a?(Symbol)
		Nix::INDENT_STRING * (indent + 1)+ key.to_nix +
		" = " + value.to_nix(indent + 1) + ";"
	end.join("\n") + "\n" +
	Nix::INDENT_STRING * indent + "}"
end