Method: Rbeapi::Api::Entity#command_builder
- Defined in:
- lib/rbeapi/api.rb
#command_builder(cmd, opts = {}) ⇒ String
Method called to build the correct version of a command based on the modifier options. If value option is set then it is appended to the command. If the enable option is false then the ‘no’ keyword is prefixed to the command. If the default value is provided and set to true, then the default keyword is used. If both options are provided, then default option takes precedence.
158 159 160 161 162 163 164 165 |
# File 'lib/rbeapi/api.rb', line 158 def command_builder(cmd, opts = {}) enable = opts.fetch(:enable, true) default = opts.fetch(:default, false) cmd << " #{opts[:value]}" if opts[:value] return "default #{cmd}" if default return "no #{cmd}" unless enable cmd end |