Class: CommandEntry
- Inherits:
-
Object
- Object
- CommandEntry
- Defined in:
- lib/easy_type/command_entry.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Class Method Summary collapse
-
.set_binding(the_binding) ⇒ Object
rubocop:disable ClassVars.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(command, arguments, options = {}) ⇒ CommandEntry
constructor
rubocop:enable ClassVars.
Constructor Details
#initialize(command, arguments, options = {}) ⇒ CommandEntry
rubocop:enable ClassVars
18 19 20 21 22 |
# File 'lib/easy_type/command_entry.rb', line 18 def initialize(command, arguments, = {}) @command = command @arguments = arguments.is_a?(Array) ? arguments : [arguments] @options = end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
10 11 12 |
# File 'lib/easy_type/command_entry.rb', line 10 def arguments @arguments end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
10 11 12 |
# File 'lib/easy_type/command_entry.rb', line 10 def command @command end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
10 11 12 |
# File 'lib/easy_type/command_entry.rb', line 10 def context @context end |
Class Method Details
.set_binding(the_binding) ⇒ Object
rubocop:disable ClassVars
13 14 15 |
# File 'lib/easy_type/command_entry.rb', line 13 def self.set_binding(the_binding) @@binding = the_binding end |
Instance Method Details
#execute ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/easy_type/command_entry.rb', line 24 def execute normalized_command = '' normalized_command = command.to_sym if @@binding.methods.include?(normalized_command) @@binding.send(normalized_command, normalized_arguments, @options) else full_command = arguments.dup.unshift(command).join(' ') Puppet::Util::Execution.execute(full_command, :failonfail => true) end end |