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.



10
11
12
# File 'lib/byebug/command_list.rb', line 10

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

Instance Method Details

#eachObject



18
19
20
# File 'lib/byebug/command_list.rb', line 18

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

#match(input) ⇒ Object



14
15
16
# File 'lib/byebug/command_list.rb', line 14

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

#to_sObject



22
23
24
# File 'lib/byebug/command_list.rb', line 22

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