Class: Bcome::WorkspaceContext

Inherits:
Object
  • Object
show all
Defined in:
lib/workspace_context.rb

Overview

TODO Move to include

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



3
4
5
# File 'lib/workspace_context.rb', line 3

def object
  @object
end

Instance Method Details

#has_object?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/workspace_context.rb', line 25

def has_object?
  !self.object.nil?
end

#irb_promptObject



33
34
35
# File 'lib/workspace_context.rb', line 33

def irb_prompt
  @object ? @object.send(:become_identifier) : start_prompt
end

#set(object, current_object, spawn = true) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/workspace_context.rb', line 5

def set(object, current_object, spawn = true)

  @object = object
  main_context = IRB.conf[:MAIN_CONTEXT]
  @object.main_context = main_context.workspace if main_context
  @object.previous_workspace_object = current_object if current_object

  irb = IRB::Irb.new(IRB::WorkSpace.new(@object))

  # Spawn is initiated when a user wants to shift workspace context.
  # We don't spawn whilst setting up the hierarchy for quick contexts 
  spawn_for_object(@object) if spawn
end

#spawn_for_object(object) ⇒ Object



19
20
21
22
23
# File 'lib/workspace_context.rb', line 19

def spawn_for_object(object)
  require 'irb/ext/multi-irb'
  IRB.parse_opts_with_ignoring_script
  IRB.irb nil, @object
end

#start_promptObject



29
30
31
# File 'lib/workspace_context.rb', line 29

def start_prompt
  ::START_PROMPT
end