Class: Moodwall::Executable

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Executable

Returns a new instance of Executable.



7
8
9
10
11
# File 'lib/moodwall/executable.rb', line 7

def initialize(options = {})
  @command   = options.fetch(:command, nil)
  @arguments = options.fetch(:arguments, nil)
  error_if_missing
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



5
6
7
# File 'lib/moodwall/executable.rb', line 5

def arguments
  @arguments
end

#commandObject (readonly)

Returns the value of attribute command.



5
6
7
# File 'lib/moodwall/executable.rb', line 5

def command
  @command
end

Instance Method Details

#error_if_missingObject



13
14
15
# File 'lib/moodwall/executable.rb', line 13

def error_if_missing
  raise(MissingExecutableError, "Can't find the `#{ command }`") unless installed?
end

#execute(path) ⇒ Object



17
18
19
# File 'lib/moodwall/executable.rb', line 17

def execute(path)
  system "#{ command } #{ arguments } #{ path }"
end