Class: VagrantPlugins::Cloudstack::Model::CloudstackResource
- Inherits:
-
Object
- Object
- VagrantPlugins::Cloudstack::Model::CloudstackResource
- Defined in:
- lib/vagrant-cloudstack/model/cloudstack_resource.rb
Instance Attribute Summary collapse
-
#details ⇒ Object
Returns the value of attribute details.
-
#id ⇒ Object
Returns the value of attribute id.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
- .create_id_list(ids, kind) ⇒ Object
- .create_list(ids, names, kind) ⇒ Object
- .create_name_list(names, kind) ⇒ Object
Instance Method Summary collapse
-
#initialize(id, name, kind) ⇒ CloudstackResource
constructor
A new instance of CloudstackResource.
- #is_id_undefined? ⇒ Boolean
- #is_name_undefined? ⇒ Boolean
- #is_undefined? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(id, name, kind) ⇒ CloudstackResource
Returns a new instance of CloudstackResource.
8 9 10 11 12 13 |
# File 'lib/vagrant-cloudstack/model/cloudstack_resource.rb', line 8 def initialize(id, name, kind) raise 'Resource must have a kind' if kind.nil? || kind.empty? @id = id @name = name @kind = kind end |
Instance Attribute Details
#details ⇒ Object
Returns the value of attribute details.
5 6 7 |
# File 'lib/vagrant-cloudstack/model/cloudstack_resource.rb', line 5 def details @details end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/vagrant-cloudstack/model/cloudstack_resource.rb', line 5 def id @id end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
6 7 8 |
# File 'lib/vagrant-cloudstack/model/cloudstack_resource.rb', line 6 def kind @kind end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/vagrant-cloudstack/model/cloudstack_resource.rb', line 5 def name @name end |
Class Method Details
.create_id_list(ids, kind) ⇒ Object
37 38 39 40 41 |
# File 'lib/vagrant-cloudstack/model/cloudstack_resource.rb', line 37 def self.create_id_list(ids, kind) ids.each_with_object([]) do |id, resources| resources << CloudstackResource.new(id, nil, kind) end end |
.create_list(ids, names, kind) ⇒ Object
31 32 33 34 35 |
# File 'lib/vagrant-cloudstack/model/cloudstack_resource.rb', line 31 def self.create_list(ids, names, kind) return create_id_list(ids, kind) unless ids.empty? return create_name_list(names, kind) unless names.empty? [] end |
.create_name_list(names, kind) ⇒ Object
43 44 45 46 47 |
# File 'lib/vagrant-cloudstack/model/cloudstack_resource.rb', line 43 def self.create_name_list(names, kind) names.each_with_object([]) do |name, resources| resources << CloudstackResource.new(nil, name, kind) end end |
Instance Method Details
#is_id_undefined? ⇒ Boolean
19 20 21 |
# File 'lib/vagrant-cloudstack/model/cloudstack_resource.rb', line 19 def is_id_undefined? id.nil? || id.empty? end |
#is_name_undefined? ⇒ Boolean
23 24 25 |
# File 'lib/vagrant-cloudstack/model/cloudstack_resource.rb', line 23 def is_name_undefined? name.nil? || name.empty? end |
#is_undefined? ⇒ Boolean
15 16 17 |
# File 'lib/vagrant-cloudstack/model/cloudstack_resource.rb', line 15 def is_undefined? is_id_undefined? and is_name_undefined? end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/vagrant-cloudstack/model/cloudstack_resource.rb', line 27 def to_s "#{kind} - #{id || '<unknown id>'}:#{name || '<unknown name>'}" end |