Class: Groundskeeper::Executable

Inherits:
Object
  • Object
show all
Defined in:
lib/groundskeeper/executable.rb

Overview

Class to execute commands for other classes

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command) ⇒ Executable

Returns a new instance of Executable.



18
19
20
21
22
23
24
# File 'lib/groundskeeper/executable.rb', line 18

def initialize(command)
  if `which #{command}`.empty?
    raise "#{command} not found, is it installed on your PATH?"
  end

  @command = command
end

Class Attribute Details

.verboseObject

Returns the value of attribute verbose.



15
16
17
# File 'lib/groundskeeper/executable.rb', line 15

def verbose
  @verbose
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



6
7
8
# File 'lib/groundskeeper/executable.rb', line 6

def command
  @command
end

Instance Method Details

#execute(arguments) ⇒ Object



26
27
28
29
# File 'lib/groundskeeper/executable.rb', line 26

def execute(arguments)
  puts "#{command} #{arguments}" if self.class.verbose
  `#{command} #{arguments}`
end