Class: Moodwall::Executable

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, config = Config.new) ⇒ Executable

Returns a new instance of Executable.



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

def initialize(options = {}, config = Config.new)
  @config    = config.executable
  @command   = options.fetch(:command, @config.command)
  @arguments = options.fetch(:arguments, @config.arguments)
  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

Class Method Details

.execute(path) ⇒ Object



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

def self.execute(path)
  new.execute(path)
end

Instance Method Details

#error_if_missingObject



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

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

#execute(path) ⇒ Object



22
23
24
# File 'lib/moodwall/executable.rb', line 22

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