Class: Ripl::Shell

Inherits:
Object
  • Object
show all
Includes:
API
Defined in:
lib/ripl/shell.rb

Defined Under Namespace

Modules: API

Constant Summary collapse

OPTIONS =
{
  :name => 'ripl',
  :result_prompt => '=> ',
  :prompt => '>> ',
  :binding => TOPLEVEL_BINDING,
  :irbrc=>'~/.irbrc'
}
EXIT_WORDS =
[nil, 'exit', 'quit']

Constants included from API

API::MESSAGES

Instance Attribute Summary collapse

Attributes included from API

#prompt, #result_prompt

Class Method Summary collapse

Instance Method Summary collapse

Methods included from API

#add_commands, #after_loop, #before_loop, #eval_input, #format_error, #format_result, #get_input, #handle_interrupt, #in_loop, #loop_eval, #loop_once, #print_eval_error, #print_result

Constructor Details

#initialize(options = {}) ⇒ Shell

Returns a new instance of Shell.


25
26
27
28
29
30
# File 'lib/ripl/shell.rb', line 25

def initialize(options={})
  options = OPTIONS.merge options
  @name, @binding = options.values_at(:name, :binding)
  @prompt, @result_prompt = options.values_at(:prompt, :result_prompt)
  @irbrc, @line = options[:irbrc], 1
end

Instance Attribute Details

#bindingObject

Returns the value of attribute binding


24
25
26
# File 'lib/ripl/shell.rb', line 24

def binding
  @binding
end

#inputObject

Returns the value of attribute input


24
25
26
# File 'lib/ripl/shell.rb', line 24

def input
  @input
end

#lineObject

Returns the value of attribute line


24
25
26
# File 'lib/ripl/shell.rb', line 24

def line
  @line
end

#nameObject

Returns the value of attribute name


24
25
26
# File 'lib/ripl/shell.rb', line 24

def name
  @name
end

#resultObject

Returns the value of attribute result


24
25
26
# File 'lib/ripl/shell.rb', line 24

def result
  @result
end

Class Method Details

.create(options = {}) ⇒ Object


2
3
4
5
6
7
8
9
10
11
# File 'lib/ripl/shell.rb', line 2

def self.create(options={})
  if options[:readline]
    require options[:readline] == true ? 'readline' : options[:readline]
    require 'ripl/readline'
  end
  require 'ripl/completion' if options[:completion]
  new(options)
rescue LoadError
  new(options)
end

Instance Method Details

#configObject


39
# File 'lib/ripl/shell.rb', line 39

def config() Ripl.config end

#loopObject

Loops shell until user exits


33
34
35
36
37
# File 'lib/ripl/shell.rb', line 33

def loop
  before_loop
  in_loop
  after_loop
end