# # # {:metadata=>{"buenas si"=>"no tanto ya", "hola"=>"adios"}, # :type=>"application/vnd.vmware.vcloud.metadata+xml", # :href=> # "https://example.com/api/vApp/vm-18545e82-d919-4071-ae7e-d1300d9d8112/metadata", # :id=>"vm-18545e82-d919-4071-ae7e-d1300d9d8112"} # # # # buenas si # no tanto ya # # # hola # adios # # module Fog module Generators module Compute module VcloudDirector class MetadataBase attr_reader :attrs def initialize(attrs={}) @attrs = attrs end def generate_xml output = "" output << header attrs[:metadata].each_pair do |k,v| output << metadata_entry(k,v) end output << tail output end def add_item(k,v) @attrs[:metadata].merge!(Hash[k,v]) end # 1.5 def header ' ' end def metadata_entry raise "This is an abstract class. Use the appropriate subclass" end # 5.1 #def header # '' #end def tail '' end end class MetadataV51 < MetadataBase def metadata_entry(key,value) body = < #{key} #{value} EOF end end class MetadataV15 < MetadataBase def metadata_entry(key,value) body = < #{key} #{value} EOF end end # end end end end