Class: QuickAndRuby::Data::Browser

Inherits:
Object
  • Object
show all
Defined in:
lib/quick_and_ruby/data/browser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_context) ⇒ Browser

Returns a new instance of Browser.



10
11
12
# File 'lib/quick_and_ruby/data/browser.rb', line 10

def initialize(root_context)
  @root_context = root_context
end

Instance Attribute Details

#root_contextObject (readonly)

Returns the value of attribute root_context.



8
9
10
# File 'lib/quick_and_ruby/data/browser.rb', line 8

def root_context
  @root_context
end

Instance Method Details

#mainObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/quick_and_ruby/data/browser.rb', line 14

def main
  command = nil
  current_context = root_context

  Reline.completion_proc = lambda { |input|
    current_context.completions(input)
  }

  while command != 'exit'
    command = Reline.readline("#{current_context.pwd}> ", true)
    break if command.nil?

    current_context = execute_command(command.strip, current_context)
  end
end