Class: IRB::Command::Base
| Relationships & Source Files | |
| Extension / Inclusion / Inheritance Descendants | |
|
Subclasses:
Backtrace, Break, CD, Catch, ChangeWorkspace, Context, Continue, Copy, CurrentWorkingWorkspace, Debug, DebugCommand, Delete, DisableIrb, Edit, Exit, Finish, ForceExit, Foreground, Help, History, Info, IrbCommand, IrbInfo, Jobs, Kill, Load, LoaderCommand, Ls, Measure, MultiIRBCommand, Next, PopWorkspace, PushWorkspace, Require, ShowDoc, ShowSource, Source, Step, Whereami, Workspaces
|
|
| Inherits: | Object |
| Defined in: | lib/irb/command/base.rb |
Class Method Summary
- .category(category = nil)
- .description(description = nil)
-
.doc_dialog_content(name, width)
Returns formatted lines for display in the doc dialog popup.
- .execute(irb_context, arg)
- .help_message(help_message = nil)
- .new(irb_context) ⇒ Base constructor
- .highlight(text) private
- .wrap_lines(text, width) private
Instance Attribute Summary
- #irb_context readonly
Instance Method Summary
Constructor Details
.new(irb_context) ⇒ Base
# File 'lib/irb/command/base.rb', line 82
def initialize(irb_context) @irb_context = irb_context end
Class Method Details
.category(category = nil)
[ GitHub ]# File 'lib/irb/command/base.rb', line 19
def category(category = nil) @category = category if category @category || "No category" end
.description(description = nil)
[ GitHub ]# File 'lib/irb/command/base.rb', line 24
def description(description = nil) @description = description if description @description || "No description provided." end
.doc_dialog_content(name, width)
Returns formatted lines for display in the doc dialog popup.
# File 'lib/irb/command/base.rb', line 41
def doc_dialog_content(name, width) lines = [] lines << Color.colorize(name, [:BOLD, :BLUE]) + Color.colorize(" (command)", [:CYAN]) lines << "" lines.concat(wrap_lines(description, width)) if lines << "" lines.concat(wrap_lines(, width)) end lines end
.execute(irb_context, arg)
[ GitHub ]# File 'lib/irb/command/base.rb', line 34
def execute(irb_context, arg) new(irb_context).execute(arg) rescue CommandArgumentError => e puts e. end
.help_message(help_message = nil)
[ GitHub ]# File 'lib/irb/command/base.rb', line 29
def ( = nil) @help_message = if @help_message end
.highlight(text) (private)
[ GitHub ].wrap_lines(text, width) (private)
[ GitHub ]# File 'lib/irb/command/base.rb', line 59
def wrap_lines(text, width) text.lines.flat_map do |line| line = line.chomp next [''] if line.empty? next [line] if line.length <= width indent = line[/\A\s*/] parts = line.strip.split(/(\s+)/) result = [] current = indent.dup parts.each do |part| if current != indent && current.length + part.length > width result << current.rstrip current = indent.dup end current << part unless current == indent && part.match?(/\A\s+\z/) end result << current.rstrip unless current == indent result end end
Instance Attribute Details
#irb_context (readonly)
[ GitHub ]# File 'lib/irb/command/base.rb', line 86
attr_reader :irb_context
Instance Method Details
#execute(arg)
[ GitHub ]# File 'lib/irb/command/base.rb', line 88
def execute(arg) #nop end