Class: ConsoleBuddy::Byebug::BuddyCommand

Inherits:
Byebug::Command
  • Object
show all
Includes:
IRB
Defined in:
lib/console_buddy/byebug/buddy_command.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from IRB

#buddy

Methods included from Report

#table_for, #table_print

Methods included from HttpRequest

#ping

Methods included from CSV

#generate_csv, #read_csv

Class Method Details

.buddyObject



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

def self.buddy
  ::ConsoleBuddy::Base.new
end

.regexpObject

Return a regex to match the “buddy” command input.

Example: buddy.ping “example.com



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

def self.regexp
  /^\s*buddy(?:\.(\w+))?\s*(.*)$/
end

Instance Method Details

#executeObject

Execute the command.



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/console_buddy/byebug/buddy_command.rb', line 25

def execute
  method_name = @match[1]
  args = @match[2]

  if method_name
    result = self.class.buddy.send(method_name, *parse_args(args))
    puts result
  else
    puts "Buddy command executed"
  end
end

#long_descriptionObject

Long description shown in the ‘help <command>’ output.



47
48
49
# File 'lib/console_buddy/byebug/buddy_command.rb', line 47

def long_description
  "Executes buddy commands with optional method calls, e.g., buddy.ping"
end

#short_descriptionObject

Short description shown in the ‘help’ output.



40
41
42
# File 'lib/console_buddy/byebug/buddy_command.rb', line 40

def short_description
  "Executes buddy commands"
end