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
93 94 95 |
# File 'lib/cluster/instance.rb', line 93 def create(*args) new(*args).start! end |
Instance Method Details
#disable(service_list) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/cluster/instance.rb', line 66 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
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/cluster/instance.rb', line 54 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
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/cluster/instance.rb', line 76 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 "#{friendly_name}\t#{svs}\t#{state}\t#{id}\t#{dns}" else label or id end end |