Class: Break::IRB::Frontend

Inherits:
Object
  • Object
show all
Defined in:
lib/break/irb/frontend.rb

Instance Method Summary collapse

Constructor Details

#initializeFrontend

Returns a new instance of Frontend.



7
8
9
# File 'lib/break/irb/frontend.rb', line 7

def initialize
  IRB.setup caller_locations.first.path, argv: []
end

Instance Method Details

#attach(session) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/break/irb/frontend.rb', line 11

def attach(session)
  @workspace = IRB::WorkSpace.new(session.context.binding)

  begin
    @irb = IRB::Irb.new(@workspace)
    @irb.context.main.extend Commands.new(session)
  rescue TypeError
    return
  end

  where

  @irb.suspend_context special_case_next_eval(@irb.context) do
    @irb.run(IRB.conf)
  end
end

#detachObject



28
29
30
# File 'lib/break/irb/frontend.rb', line 28

def detach
  @irb&.context&.exit
end

#notify(message) ⇒ Object



36
37
38
# File 'lib/break/irb/frontend.rb', line 36

def notify(message)
  puts message
end

#whereObject



32
33
34
# File 'lib/break/irb/frontend.rb', line 32

def where
  puts @workspace.code_around_binding if @workspace
end