Class: Misty::Services

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/misty/services.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeServices

Returns a new instance of Services.



9
10
11
# File 'lib/misty/services.rb', line 9

def initialize
  @services = []
end

Instance Attribute Details

#servicesObject (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

#eachObject



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

#namesObject



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_sObject



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