Class: Shred::Commands::Services::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/shred/commands/services.rb

Direct Known Subclasses

LaunchctlService, ShellCommandService

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sym: nil) ⇒ Service

Returns a new instance of Service.



11
12
13
# File 'lib/shred/commands/services.rb', line 11

def initialize(sym: nil)
  @sym = sym
end

Instance Attribute Details

#symObject (readonly)

Returns the value of attribute sym.



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

def sym
  @sym
end

Instance Method Details

#start(ctx, command_lines) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/shred/commands/services.rb', line 15

def start(ctx, command_lines)
  ctx.run_shell_command(ShellCommand.new(
    command_lines: command_lines,
    success_msg: "#{sym} started",
    error_msg: "#{sym} could not be started"
  ))
end

#stop(ctx, command_lines) ⇒ Object



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

def stop(ctx, command_lines)
  ctx.run_shell_command(ShellCommand.new(
    command_lines: command_lines,
    success_msg: "#{sym} stopped",
    error_msg: "#{sym} could not be stopped"
  ))
end