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.



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

def initialize
  @services = []
end

Instance Attribute Details

#servicesObject (readonly)

Returns the value of attribute services.



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

def services
  @services
end

Instance Method Details

#add(*args) ⇒ Object



14
15
16
# File 'lib/misty/services.rb', line 14

def add(*args)
  @services << Misty::Service.new(*args)
end

#eachObject



18
19
20
21
22
# File 'lib/misty/services.rb', line 18

def each
  @services.each do |s|
    yield s
  end
end

#get(name) ⇒ Object



24
25
26
27
28
29
# File 'lib/misty/services.rb', line 24

def get(name)
  each do |s|
    return s if s.name == name
  end
  nil
end

#to_sObject



39
40
41
42
43
44
45
# File 'lib/misty/services.rb', line 39

def to_s
  list = ''
  each do |service|
    list << service.to_s + "\n"
  end
  list
end

#typesObject



31
32
33
34
35
36
37
# File 'lib/misty/services.rb', line 31

def types
  list = []
  each do |s|
    list << s.type
  end
  list
end