Class: Resty::Repl

Inherits:
Object
  • Object
show all
Includes:
Readline
Defined in:
lib/resty/repl.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resty_options) ⇒ Repl

Returns a new instance of Repl.



9
10
11
12
13
14
15
16
17
# File 'lib/resty/repl.rb', line 9

def initialize(resty_options)
  @options = Resty::Options.new(resty_options)

  Pry.config.prompt = [ proc { "resty> " }, proc { "*>" }]
  Pry.config.history.file = "~/.ruby_resty_history"
  Pry.config.print = proc do |output, value|
    output.puts(Resty::PrettyPrinter.new(options, value).generate)
  end
end

Instance Attribute Details

#interruptedObject

Returns the value of attribute interrupted.



7
8
9
# File 'lib/resty/repl.rb', line 7

def interrupted
  @interrupted
end

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'lib/resty/repl.rb', line 7

def options
  @options
end

Class Method Details

.start(resty_options) ⇒ Object



19
20
21
22
23
24
# File 'lib/resty/repl.rb', line 19

def self.start(resty_options)
  new(resty_options).tap do |repl|
    Pry.config.input = repl
    repl.options.pry
  end
end

Instance Method Details

#readline(current_prompt) ⇒ Object



26
27
28
# File 'lib/resty/repl.rb', line 26

def readline(current_prompt)
  Readline.readline(current_prompt)
end