Class: ForemanMaintain::Utils::Service::Abstract
- Inherits:
-
Object
- Object
- ForemanMaintain::Utils::Service::Abstract
- Includes:
- Comparable
- Defined in:
- lib/foreman_maintain/utils/service/abstract.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #disable ⇒ Object
- #enable ⇒ Object
- #exist? ⇒ Boolean
-
#initialize(name, priority, options = {}) ⇒ Abstract
constructor
A new instance of Abstract.
- #inspect ⇒ Object
- #matches?(service) ⇒ Boolean
- #running? ⇒ Boolean
- #socket ⇒ Object
- #start ⇒ Object
- #status ⇒ Object
- #stop ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, priority, options = {}) ⇒ Abstract
Returns a new instance of Abstract.
7 8 9 10 11 |
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 7 def initialize(name, priority, = {}) @name = name @priority = priority @options = end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 5 def name @name end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
5 6 7 |
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 5 def priority @priority end |
Instance Method Details
#<=>(other) ⇒ Object
19 20 21 22 |
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 19 def <=>(other) prio_cmp = @priority <=> other.priority (prio_cmp == 0) ? @name <=> other.name : prio_cmp end |
#disable ⇒ Object
62 63 64 |
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 62 def disable raise NotImplementedError end |
#enable ⇒ Object
58 59 60 |
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 58 def enable raise NotImplementedError end |
#exist? ⇒ Boolean
42 43 44 |
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 42 def exist? raise NotImplementedError end |
#inspect ⇒ Object
28 29 30 |
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 28 def inspect "#{self.class.name.split('::').last}(#{@name} [#{@priority}])" end |
#matches?(service) ⇒ Boolean
32 33 34 35 36 37 38 39 40 |
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 32 def matches?(service) if service.is_a? String service == @name elsif service.instance_of?(self.class) service.name == @name else false end end |
#running? ⇒ Boolean
66 67 68 |
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 66 def running? raise NotImplementedError end |
#socket ⇒ Object
13 14 15 16 17 |
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 13 def socket if @options[:socket] self.class.new("#{@options[:socket]}.socket", priority) end end |
#start ⇒ Object
50 51 52 |
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 50 def start raise NotImplementedError end |
#status ⇒ Object
46 47 48 |
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 46 def status raise NotImplementedError end |
#stop ⇒ Object
54 55 56 |
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 54 def stop raise NotImplementedError end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 24 def to_s @name end |