Class: SvCtl::Service
- Inherits:
-
Object
- Object
- SvCtl::Service
- Defined in:
- lib/svctl/service.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#runlevel ⇒ Object
readonly
Returns the value of attribute runlevel.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #disable ⇒ Object
- #dst_path(runlevel = nil) ⇒ Object protected
- #enable ⇒ Object
- #enabled? ⇒ Boolean
- #exist? ⇒ Boolean
-
#initialize(name, runlevel) ⇒ Service
constructor
A new instance of Service.
- #runlevels ⇒ Object
- #src_path ⇒ Object protected
Constructor Details
#initialize(name, runlevel) ⇒ Service
Returns a new instance of Service.
5 6 7 8 |
# File 'lib/svctl/service.rb', line 5 def initialize(name, runlevel) @name = name @runlevel = runlevel end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/svctl/service.rb', line 3 def name @name end |
#runlevel ⇒ Object (readonly)
Returns the value of attribute runlevel.
3 4 5 |
# File 'lib/svctl/service.rb', line 3 def runlevel @runlevel end |
Instance Method Details
#<=>(other) ⇒ Object
36 37 38 |
# File 'lib/svctl/service.rb', line 36 def <=>(other) name <=> other.name end |
#disable ⇒ Object
22 23 24 |
# File 'lib/svctl/service.rb', line 22 def disable File.unlink(dst_path) end |
#dst_path(runlevel = nil) ⇒ Object (protected)
46 47 48 |
# File 'lib/svctl/service.rb', line 46 def dst_path(runlevel = nil) File.join(SvCtl::RUNSVDIR, runlevel || self.runlevel, name) end |
#enable ⇒ Object
18 19 20 |
# File 'lib/svctl/service.rb', line 18 def enable File.symlink(src_path, dst_path) end |
#enabled? ⇒ Boolean
14 15 16 |
# File 'lib/svctl/service.rb', line 14 def enabled? File.symlink?(dst_path) end |
#exist? ⇒ Boolean
10 11 12 |
# File 'lib/svctl/service.rb', line 10 def exist? Dir.exist?(src_path) end |
#runlevels ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/svctl/service.rb', line 26 def runlevels ret = [] SvCtl.runlevels.each do |v| ret << v if Dir.exist?(dst_path(v)) end ret end |
#src_path ⇒ Object (protected)
42 43 44 |
# File 'lib/svctl/service.rb', line 42 def src_path File.join(SvCtl::SERVICE_DIR, name) end |