Module: Bombshell::Shell

Includes:
Commands
Defined in:
lib/bombshell/shell.rb,
lib/bombshell/shell/commands.rb

Overview

Classes include this module to become Bombshell shells.

Defined Under Namespace

Modules: ClassMethods, Commands

Constant Summary

Constants included from Commands

Commands::HIDE

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Commands

#method_missing, #quit

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Bombshell::Shell::Commands

Class Method Details

.included(base) ⇒ Object

Add class methods and a callback hash to your shell.



7
8
9
10
# File 'lib/bombshell/shell.rb', line 7

def self.included(base)
  base.extend ClassMethods
  base.instance_variable_set :@bombshell_callbacks, :before_launch => [], :having_launched => []
end

Instance Method Details

#_promptObject

Render and return your shell’s prompt.

You can define the prompt with MyShell.prompt_with and access it without rendering with MyShell.bombshell_prompt.



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/bombshell/shell.rb', line 26

def _prompt
  if self.class.bombshell_prompt.is_a? String
    self.class.bombshell_prompt
  elsif self.class.bombshell_prompt.is_a? Proc and self.class.bombshell_prompt.arity == 1
    self.class.bombshell_prompt.call self
  elsif self.class.bombshell_prompt.is_a? Proc
    self.class.bombshell_prompt.call
  else
    '[Bombshell]'
  end
end

#get_bindingObject

Returns your shell’s binding, which IRB needs (desperately).

Returns:

  • Binding



40
41
42
# File 'lib/bombshell/shell.rb', line 40

def get_binding
  binding
end

#to_sObject

IRB has pretty limited hooks for defining prompts, so we have to piggyback on your shell’s #to_s. Hope you don’t need it for something else.



14
15
16
# File 'lib/bombshell/shell.rb', line 14

def to_s
  _prompt
end