Class: Byebug::CommandList
- Inherits:
-
Object
- Object
- Byebug::CommandList
- Includes:
- Enumerable
- Defined in:
- lib/byebug/command_list.rb
Overview
Holds an array of subcommands for a command
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(commands) ⇒ CommandList
constructor
A new instance of CommandList.
- #match(input) ⇒ Object
- #to_s ⇒ Object
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
#each ⇒ Object
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_s ⇒ Object
24 25 26 |
# File 'lib/byebug/command_list.rb', line 24 def to_s "\n" + map { |cmd| cmd.columnize(width) }.join + "\n" end |