Class: Hash

Inherits:
Object
  • Object
show all
Includes:
ActiveSupport::CoreExtensions::Hash::Keys, ActiveSupport::CoreExtensions::Hash::ReverseMerge
Defined in:
lib/ruby-xen.rb,
lib/ruby-xen.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#to_argsObject

Converts a Hash into an array of key=val formatted strings

puts { :nics => 2, :vcpus => 1, :memory => 64, :dhcp => true }.to_args

produces:

“–memory=64”, “–nics=2”, “–vcpus=1”, “–dhcp”


57
58
59
# File 'lib/ruby-xen.rb', line 57

def to_args
  collect{|k,v| (v.to_s == 'true') ? "--#{k.to_s}" : "--#{k.to_s}=#{v}"}
end