module Bombshell::Shell

Classes include this module to become Bombshell shells.

Public Class Methods

included(base) click to toggle source

Add class methods and a callback hash to your shell.

# 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

Public Instance Methods

_prompt() click to toggle source

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. @see ClassMethods#prompt_with @see ClassMethods#bombshell_prompt @return String

# 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_binding() click to toggle source

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

# File lib/bombshell/shell.rb, line 40
def get_binding
  binding
end
to_s() click to toggle source

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.

# File lib/bombshell/shell.rb, line 14
def to_s
  _prompt
end