Class: Moodwall::Executable
- Inherits:
-
Object
- Object
- Moodwall::Executable
- Defined in:
- lib/moodwall/executable.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
Class Method Summary collapse
Instance Method Summary collapse
- #error_if_missing ⇒ Object
- #execute(path) ⇒ Object
-
#initialize(options = {}, config = Config.new) ⇒ Executable
constructor
A new instance of Executable.
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( = {}, config = Config.new) @config = config.executable @command = .fetch(:command, @config.command) @arguments = .fetch(:arguments, @config.arguments) error_if_missing end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
5 6 7 |
# File 'lib/moodwall/executable.rb', line 5 def arguments @arguments end |
#command ⇒ Object (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_missing ⇒ Object
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 |