Method: RbVmomi::Connection.type

Defined in:
lib/rbvmomi/connection.rb

.type(name) ⇒ Object



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/rbvmomi/connection.rb', line 197

def self.type name
  fail unless name and (name.is_a? String or name.is_a? Symbol)
  name = $' if name.to_s =~ /^xsd:/
  case name.to_sym
  when :anyType then BasicTypes::AnyType
  when :boolean then BasicTypes::Boolean
  when :string then String
  when :int, :long, :short, :byte then Integer
  when :float, :double then Float
  when :dateTime then Time
  when :base64Binary then BasicTypes::Binary
  when :KeyValue then BasicTypes::KeyValue
  else
    first_char = name[0].chr
    if first_char.downcase == first_char
      name = "%s%s" % [first_char.upcase, name[1..-1]]
    end

    if @loader.has? name
      const_get(name)
    else
      fail "no such type #{name.inspect}"
    end
  end
end