Class: LSL::Completion::Mapping

Inherits:
Object
  • Object
show all
Includes:
FromHash
Defined in:
lib/lsl/command/completion.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#command_matcherObject

Returns the value of attribute command_matcher.



30
31
32
# File 'lib/lsl/command/completion.rb', line 30

def command_matcher
  @command_matcher
end

#option_generatorObject

Returns the value of attribute option_generator.



30
31
32
# File 'lib/lsl/command/completion.rb', line 30

def option_generator
  @option_generator
end

Instance Method Details

#match?(cmd) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/lsl/command/completion.rb', line 39

def match?(cmd)
  cmd =~ command_matcher
end

#optionsObject



31
32
33
34
35
36
37
38
# File 'lib/lsl/command/completion.rb', line 31

def options
  res = if option_generator.kind_of?(String)
    base.shell.run(option_generator).result
  else
    option_generator.call
  end
  [res].flatten.select { |x| x }
end