Class: Byebug::CommandList

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/byebug/command_list.rb

Overview

Holds an array of subcommands for a command

Instance Method Summary collapse

Constructor Details

#initialize(commands) ⇒ CommandList

Returns a new instance of CommandList.



12
13
14
# File 'lib/byebug/command_list.rb', line 12

def initialize(commands)
  @commands = commands.sort_by(&:to_s)
end

Instance Method Details

#eachObject



20
21
22
# File 'lib/byebug/command_list.rb', line 20

def each
  @commands.each { |cmd| yield(cmd) }
end

#match(input) ⇒ Object



16
17
18
# File 'lib/byebug/command_list.rb', line 16

def match(input)
  find { |cmd| cmd.match(input) }
end

#to_sObject



24
25
26
# File 'lib/byebug/command_list.rb', line 24

def to_s
  "\n" + map { |cmd| cmd.columnize(width) }.join + "\n"
end