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.
10 11 12 |
# File 'lib/byebug/command_list.rb', line 10 def initialize(commands) @commands = commands.sort_by(&:to_s) end |
Instance Method Details
#each ⇒ Object
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_s ⇒ Object
22 23 24 |
# File 'lib/byebug/command_list.rb', line 22 def to_s "\n" + map { |cmd| cmd.columnize(width) }.join + "\n" end |