Class: RbVmomi::VIM::DataObject

Inherits:
ObjectWithProperties show all
Defined in:
lib/rbvmomi/types.rb

Direct Known Subclasses

LocalizedMethodFault, MethodFault

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ObjectWithProperties

find_prop_desc, full_props_desc, initialize

Methods inherited from Base

initialize, to_s

Constructor Details

#initialize(props = {}) ⇒ DataObject

Returns a new instance of DataObject.



171
172
173
174
175
176
177
178
179
# File 'lib/rbvmomi/types.rb', line 171

def initialize props={}
  @props = Hash[props.map { |k,v| [k.to_sym, v] }]
  self.class.full_props_desc.each do |desc|
    #fail "missing required property #{desc['name'].inspect} of #{self.class.wsdl_name}" if @props[desc['name'].to_sym].nil? and not desc['is-optional']
  end
  @props.each do |k,v|
    fail "unexpected property name #{k}" unless self.class.find_prop_desc(k)
  end
end

Instance Attribute Details

#propsObject (readonly)

Returns the value of attribute props.



169
170
171
# File 'lib/rbvmomi/types.rb', line 169

def props
  @props
end

Instance Method Details

#==(o) ⇒ Object



193
194
195
196
197
# File 'lib/rbvmomi/types.rb', line 193

def == o
  return false unless o.class == self.class
  keys = (props.keys + o.props.keys).uniq
  keys.all? { |k| props[k] == o.props[k] }
end

#[](sym) ⇒ Object



185
186
187
# File 'lib/rbvmomi/types.rb', line 185

def [] sym
  _get_property sym
end

#_get_property(sym) ⇒ Object



181
182
183
# File 'lib/rbvmomi/types.rb', line 181

def _get_property sym
  @props[sym]
end

#_set_property(sym, val) ⇒ Object



189
190
191
# File 'lib/rbvmomi/types.rb', line 189

def _set_property sym, val
  @props[sym] = val
end

#hashObject



199
200
201
# File 'lib/rbvmomi/types.rb', line 199

def hash
  props.hash
end

#pretty_print(q) ⇒ Object



203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/rbvmomi/types.rb', line 203

def pretty_print q
  q.text self.class.name
  q.group 2 do
    q.text '('
    q.breakable
    props = @props.sort_by { |k,v| k.to_s }
    q.seplist props, nil, :each do |k, v|
      q.group do
        q.text k.to_s
        q.text ': '
        q.pp v
      end
    end
  end
  q.breakable
  q.text ')'
end