Module: Harp

Defined in:
lib/harp.rb

Defined Under Namespace

Classes: REPL

Class Method Summary collapse

Class Method Details

.included(mod) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/harp.rb', line 11

def self.included(mod)
  mod.module_eval do
    @dispatcher = Dispatcher.new

    def self.setup_harp(&block)
      dispatcher = @dispatcher
      # This should either be baked in to REPL, or non-existent.
      @dispatcher.command("quit") do
        exit
      end
      @dispatcher.instance_exec(dispatcher, &block)
    end

    def self.repl
      REPL.new(@dispatcher)
    end

    def repl
      self.class.repl.run(self)
    end
  end
end