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', :line=>1, :result_prompt=>'=> ', :prompt=>'>> ',
:binding=>TOPLEVEL_BINDING, :irbrc=>'~/.irbrc'}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from API

#after_loop, #before_loop, #during_loop, #format_error, #format_result, #get_input, #loop_eval, #loop_once, #print_eval_error, #prompt

Constructor Details

#initialize(options = {}) ⇒ Shell

Returns a new instance of Shell.



14
15
16
17
18
# File 'lib/ripl/shell.rb', line 14

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

Instance Attribute Details

#bindingObject

Returns the value of attribute binding.



13
14
15
# File 'lib/ripl/shell.rb', line 13

def binding
  @binding
end

#last_resultObject

Returns the value of attribute last_result.



13
14
15
# File 'lib/ripl/shell.rb', line 13

def last_result
  @last_result
end

#lineObject

Returns the value of attribute line.



13
14
15
# File 'lib/ripl/shell.rb', line 13

def line
  @line
end

#result_promptObject

Returns the value of attribute result_prompt.



13
14
15
# File 'lib/ripl/shell.rb', line 13

def result_prompt
  @result_prompt
end

Class Method Details

.create(options = {}) ⇒ Object



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

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

Instance Method Details

#configObject



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

def config; Ripl.config; end

#loopObject



20
21
22
23
24
# File 'lib/ripl/shell.rb', line 20

def loop
  before_loop
  during_loop
  after_loop
end