Class: OsCtl::Lib::Cli::Completion::Bash::OptArg
- Inherits:
-
Object
- Object
- OsCtl::Lib::Cli::Completion::Bash::OptArg
- Defined in:
- lib/libosctl/cli/completion/bash.rb
Instance Attribute Summary collapse
-
#cmd ⇒ Object
readonly
Returns the value of attribute cmd.
-
#expand ⇒ Object
readonly
Returns the value of attribute expand.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #applicable?(cmd_path, arg) ⇒ Boolean
-
#initialize(opts) ⇒ OptArg
constructor
A new instance of OptArg.
Constructor Details
#initialize(opts) ⇒ OptArg
Returns a new instance of OptArg.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/libosctl/cli/completion/bash.rb', line 12 def initialize(opts) @cmd = if opts[:cmd].is_a?(Symbol) opts[:cmd] else opts[:cmd].map(&:to_s) end @name = opts[:name].to_s @expand = opts[:expand] end |
Instance Attribute Details
#cmd ⇒ Object (readonly)
Returns the value of attribute cmd.
6 7 8 |
# File 'lib/libosctl/cli/completion/bash.rb', line 6 def cmd @cmd end |
#expand ⇒ Object (readonly)
Returns the value of attribute expand.
6 7 8 |
# File 'lib/libosctl/cli/completion/bash.rb', line 6 def @expand end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/libosctl/cli/completion/bash.rb', line 6 def name @name end |
Instance Method Details
#applicable?(cmd_path, arg) ⇒ Boolean
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/libosctl/cli/completion/bash.rb', line 25 def applicable?(cmd_path, arg) return false if name != arg return true if cmd == :all cmd.zip(cmd_path).each do |x, y| return false if y.nil? || x != y end true end |