Class: Misty::Services
- Inherits:
-
Object
- Object
- Misty::Services
- Includes:
- Enumerable
- Defined in:
- lib/misty/services.rb
Instance Attribute Summary collapse
-
#services ⇒ Object
readonly
Returns the value of attribute services.
Instance Method Summary collapse
- #add(*args) ⇒ Object
- #each ⇒ Object
- #get(name) ⇒ Object
-
#initialize ⇒ Services
constructor
A new instance of Services.
- #names ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Services
Returns a new instance of Services.
9 10 11 |
# File 'lib/misty/services.rb', line 9 def initialize @services = [] end |
Instance Attribute Details
#services ⇒ Object (readonly)
Returns the value of attribute services.
7 8 9 |
# File 'lib/misty/services.rb', line 7 def services @services end |
Instance Method Details
#add(*args) ⇒ Object
13 14 15 |
# File 'lib/misty/services.rb', line 13 def add(*args) @services << Misty::Service.new(*args) end |
#each ⇒ Object
17 18 19 20 21 |
# File 'lib/misty/services.rb', line 17 def each @services.each do |service| yield service end end |
#get(name) ⇒ Object
23 24 25 26 27 |
# File 'lib/misty/services.rb', line 23 def get(name) @services.each do |service| return service if service.name == name end end |
#names ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/misty/services.rb', line 29 def names service_names = [] @services.each do |service| service_names << service.name end service_names end |
#to_s ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/misty/services.rb', line 37 def to_s list = '' @services.each do |service| list << service.to_s + "\n" end list end |