Class: SvCtl::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/svctl/service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/svctl/service.rb', line 3

def name
  @name
end

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

#disableObject



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

#enableObject



18
19
20
# File 'lib/svctl/service.rb', line 18

def enable
  File.symlink(src_path, dst_path)
end

#enabled?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/svctl/service.rb', line 14

def enabled?
  File.symlink?(dst_path)
end

#exist?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/svctl/service.rb', line 10

def exist?
  Dir.exist?(src_path)
end

#runlevelsObject



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_pathObject (protected)



42
43
44
# File 'lib/svctl/service.rb', line 42

def src_path
  File.join(SvCtl::SERVICE_DIR, name)
end