Class: Instance
- Inherits:
-
Object
- Object
- Instance
- Defined in:
- lib/cluster/instance.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#disabled_services ⇒ Object
Returns the value of attribute disabled_services.
-
#friendly_name ⇒ Object
Returns the value of attribute friendly_name.
-
#groups ⇒ Object
Returns the value of attribute groups.
-
#id ⇒ Object
Returns the value of attribute id.
-
#label ⇒ Object
Returns the value of attribute label.
-
#services ⇒ Object
Returns the value of attribute services.
-
#size ⇒ Object
Returns the value of attribute size.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
-
#state ⇒ Object
Returns the value of attribute state.
Class Method Summary collapse
Instance Method Summary collapse
- #disable(service_list) ⇒ Object
- #enable(service_list) ⇒ Object
- #identified_by?(arg) ⇒ Boolean
-
#initialize(*args) ⇒ Instance
constructor
A new instance of Instance.
- #to_s(format = nil) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Instance
Returns a new instance of Instance.
16 17 18 19 20 21 22 23 24 |
# File 'lib/cluster/instance.rb', line 16 def initialize(*args) = args. .each do |key, value| func = "#{key}=" if self.respond_to? func self.send func, value end end end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
5 6 7 |
# File 'lib/cluster/instance.rb', line 5 def address @address end |
#disabled_services ⇒ Object
Returns the value of attribute disabled_services.
5 6 7 |
# File 'lib/cluster/instance.rb', line 5 def disabled_services @disabled_services end |
#friendly_name ⇒ Object
Returns the value of attribute friendly_name.
5 6 7 |
# File 'lib/cluster/instance.rb', line 5 def friendly_name @friendly_name end |
#groups ⇒ Object
Returns the value of attribute groups.
5 6 7 |
# File 'lib/cluster/instance.rb', line 5 def groups @groups end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/cluster/instance.rb', line 5 def id @id end |
#label ⇒ Object
Returns the value of attribute label.
5 6 7 |
# File 'lib/cluster/instance.rb', line 5 def label @label end |
#services ⇒ Object
Returns the value of attribute services.
5 6 7 |
# File 'lib/cluster/instance.rb', line 5 def services @services end |
#size ⇒ Object
Returns the value of attribute size.
5 6 7 |
# File 'lib/cluster/instance.rb', line 5 def size @size end |
#start_time ⇒ Object
Returns the value of attribute start_time.
5 6 7 |
# File 'lib/cluster/instance.rb', line 5 def start_time @start_time end |
#state ⇒ Object
Returns the value of attribute state.
5 6 7 |
# File 'lib/cluster/instance.rb', line 5 def state @state end |
Class Method Details
.create(*args) ⇒ Object
95 96 97 |
# File 'lib/cluster/instance.rb', line 95 def create(*args) new(*args).start! end |
Instance Method Details
#disable(service_list) ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/cluster/instance.rb', line 62 def disable(service_list) for service in service_list unless disabled_services.include? service @disabled_services = disabled_services << service end end @disabled_services end |
#enable(service_list) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/cluster/instance.rb', line 50 def enable(service_list) for service in service_list @disabled_services.delete(service) if disabled_services.include? service unless services.include? service @services = services << service end end @services end |
#identified_by?(arg) ⇒ Boolean
37 38 39 40 |
# File 'lib/cluster/instance.rb', line 37 def identified_by?(arg) arg = arg.downcase self.id == arg or self.label == arg or self.dns == arg or self.friendly_name == arg end |
#to_s(format = nil) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/cluster/instance.rb', line 72 def to_s(format = nil) case format when :long svs = if services.empty? '(N/S)' else services.map {|s| disabled_services.include?(s) ? "!#{s}" : s }.join(',') end conn = dns conn = ip if !conn or conn.empty? conn = "(#{private_ip_address})" if !conn or conn.empty? nm = friendly_name nm = '(N/N)' if !nm or nm.empty? "#{nm}\t#{svs}\t#{state}\t#{id}\t#{conn}" else label or id end end |