Class: Arql::Repl
Instance Method Summary collapse
-
#initialize ⇒ Repl
constructor
A new instance of Repl.
- #main_object ⇒ Object
- #prompt ⇒ Object
Constructor Details
#initialize ⇒ Repl
Returns a new instance of Repl.
8 9 10 11 |
# File 'lib/arql/repl.rb', line 8 def initialize Pry.config.prompt = Pry::Prompt.new("", "", prompt) Pry.start end |
Instance Method Details
#main_object ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/arql/repl.rb', line 13 def main_object return @main if @main @main = Object.new @main.instance_eval do def inspect to_s end def to_s "main" end end @main end |
#prompt ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/arql/repl.rb', line 27 def prompt [proc do |obj, nest_level, pry_instance| if obj == main_object && nest_level == 0 nest_level_prompt = '' else nest_level_prompt = if nest_level.zero? "(#{obj})" else "(#{obj}:#{nest_level})" end end if Arql::Commands::Sandbox.enabled sandbox_indicator = ' [%s] ' % Rainbow('sandbox').green.bright else sandbox_indicator = '' end "%s#{Rainbow('@').green}%s%s#{nest_level_prompt} [%d] %s " % [Rainbow('ARQL').red, Rainbow(App.prompt).yellow, sandbox_indicator, pry_instance.input_ring.count, Rainbow('❯').green] end] end |