Class: IRB::Command::Base

Inherits:
Object show all
Defined in:
lib/irb/command/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(irb_context) ⇒ Base

Returns a new instance of Base.



82
83
84
# File 'lib/irb/command/base.rb', line 82

def initialize(irb_context)
  @irb_context = irb_context
end

Instance Attribute Details

#irb_contextObject (readonly)

Returns the value of attribute irb_context.



86
87
88
# File 'lib/irb/command/base.rb', line 86

def irb_context
  @irb_context
end

Class Method Details

.category(category = nil) ⇒ Object



19
20
21
22
# File 'lib/irb/command/base.rb', line 19

def category(category = nil)
  @category = category if category
  @category || "No category"
end

.description(description = nil) ⇒ Object



24
25
26
27
# 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) ⇒ Object

Returns formatted lines for display in the doc dialog popup.



41
42
43
44
45
46
47
48
49
50
51
# 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 help_message
    lines << ""
    lines.concat(wrap_lines(help_message, width))
  end
  lines
end

.execute(irb_context, arg) ⇒ Object



34
35
36
37
38
# File 'lib/irb/command/base.rb', line 34

def execute(irb_context, arg)
  new(irb_context).execute(arg)
rescue CommandArgumentError => e
  puts e.message
end

.help_message(help_message = nil) ⇒ Object



29
30
31
32
# File 'lib/irb/command/base.rb', line 29

def help_message(help_message = nil)
  @help_message = help_message if help_message
  @help_message
end

Instance Method Details

#execute(arg) ⇒ Object



88
89
90
# File 'lib/irb/command/base.rb', line 88

def execute(arg)
  #nop
end