Module: RVC::InventoryObject
- Extended by:
- ObjectWithFields::ClassMethods
- Includes:
- ObjectWithFields
- Included in:
- LazyDVPort, Connection, FakeFolder, RootNode, RootSnapshotFolder, SnapshotFolder, RbVmomi::VIM::Datastore::FakeDatastoreFile, RbVmomi::VIM::Datastore::FakeDatastoreFolder, RbVmomi::VIM::DistributedVirtualPort, RbVmomi::VIM::ManagedEntity, RbVmomi::VIM::VirtualDevice
- Defined in:
- lib/rvc/inventory.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
field, fields
#field, #field_properties, #perfmetrics
Instance Attribute Details
#rvc_arc ⇒ Object
Returns the value of attribute rvc_arc.
57
58
59
|
# File 'lib/rvc/inventory.rb', line 57
def rvc_arc
@rvc_arc
end
|
#rvc_parent ⇒ Object
Returns the value of attribute rvc_parent.
57
58
59
|
# File 'lib/rvc/inventory.rb', line 57
def rvc_parent
@rvc_parent
end
|
Class Method Details
.included(m) ⇒ Object
49
50
51
|
# File 'lib/rvc/inventory.rb', line 49
def self.included m
m.extend ClassMethods
end
|
Instance Method Details
#children ⇒ Object
71
72
73
|
# File 'lib/rvc/inventory.rb', line 71
def children
{}
end
|
#display_info ⇒ Object
59
60
61
|
# File 'lib/rvc/inventory.rb', line 59
def display_info
puts "class: #{self.class.name}"
end
|
#ls_text(r) ⇒ Object
63
64
65
|
# File 'lib/rvc/inventory.rb', line 63
def ls_text r
self.class.folder? ? '/' : ''
end
|
#rvc_link(parent, arc) ⇒ Object
106
107
108
109
110
|
# File 'lib/rvc/inventory.rb', line 106
def rvc_link parent, arc
return if @rvc_parent
@rvc_parent = parent
@rvc_arc = arc
end
|
#rvc_path ⇒ Object
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/rvc/inventory.rb', line 75
def rvc_path
[].tap do |a|
cur = self
while cur != nil
a << [cur.rvc_arc, cur]
cur = cur.rvc_parent
end
a.reverse!
end
end
|
#rvc_path_str ⇒ Object
86
87
88
|
# File 'lib/rvc/inventory.rb', line 86
def rvc_path_str
rvc_path.map { |k,v| k } * '/'
end
|
#rvc_relative_path(ref) ⇒ Object
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/rvc/inventory.rb', line 90
def rvc_relative_path ref
my_path = rvc_path
ref_path = ref.rvc_path
ref_objs = Set.new(ref_path.map { |x| x[1] })
common = my_path.take_while { |x| ref_objs.member? x[1] }
fail unless common
path_to_ref = my_path.reverse.take_while { |x| x[1] != common.last[1] }.reverse
num_ups = ref_path.size - common.size
ups = (['..']*num_ups).zip(ref_path.reverse[1..-1].map(&:first))
ups + path_to_ref
end
|
#rvc_relative_path_str(ref) ⇒ Object
102
103
104
|
# File 'lib/rvc/inventory.rb', line 102
def rvc_relative_path_str ref
rvc_relative_path(ref).map { |k,v| k } * '/'
end
|
#traverse_one(arc) ⇒ Object
67
68
69
|
# File 'lib/rvc/inventory.rb', line 67
def traverse_one arc
children[arc]
end
|