Class: Bcome::Workspace
- Inherits:
-
Object
- Object
- Bcome::Workspace
- Includes:
- Singleton
- Defined in:
- lib/objects/workspace.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#estate ⇒ Object
readonly
Returns the value of attribute estate.
Instance Method Summary collapse
- #console_set! ⇒ Object
- #console_set? ⇒ Boolean
- #default_prompt ⇒ Object
- #has_context? ⇒ Boolean
-
#initialize ⇒ Workspace
constructor
A new instance of Workspace.
- #irb_prompt ⇒ Object
- #object_is_current_context?(object) ⇒ Boolean
- #set(params) ⇒ Object
- #spawn_into_console_for_context ⇒ Object
Constructor Details
#initialize ⇒ Workspace
Returns a new instance of Workspace.
7 8 9 10 11 |
# File 'lib/objects/workspace.rb', line 7 def initialize @context = nil @console_set = false @estate = nil end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
4 5 6 |
# File 'lib/objects/workspace.rb', line 4 def context @context end |
#estate ⇒ Object (readonly)
Returns the value of attribute estate.
5 6 7 |
# File 'lib/objects/workspace.rb', line 5 def estate @estate end |
Instance Method Details
#console_set! ⇒ Object
28 29 30 |
# File 'lib/objects/workspace.rb', line 28 def console_set! @console_set = true end |
#console_set? ⇒ Boolean
32 33 34 |
# File 'lib/objects/workspace.rb', line 32 def console_set? @console_set end |
#default_prompt ⇒ Object
54 55 56 |
# File 'lib/objects/workspace.rb', line 54 def default_prompt 'bcome' end |
#has_context? ⇒ Boolean
46 47 48 |
# File 'lib/objects/workspace.rb', line 46 def has_context? !context.nil? end |
#irb_prompt ⇒ Object
50 51 52 |
# File 'lib/objects/workspace.rb', line 50 def irb_prompt @context ? @context. : default_prompt end |
#object_is_current_context?(object) ⇒ Boolean
36 37 38 |
# File 'lib/objects/workspace.rb', line 36 def object_is_current_context?(object) @context == object end |
#set(params) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/objects/workspace.rb', line 13 def set(params) init_irb unless console_set? @context = params[:context] @context.load_nodes if @context.inventory? && !@context.nodes_loaded? main_context = IRB.conf[:MAIN_CONTEXT] @context.irb_workspace = main_context.workspace if main_context @context.previous_irb_workspace = params[:current_context] if params[:current_context] set_irb_prompt spawn_into_console_for_context nil end |
#spawn_into_console_for_context ⇒ Object
40 41 42 43 44 |
# File 'lib/objects/workspace.rb', line 40 def spawn_into_console_for_context require 'irb/ext/multi-irb' IRB.parse_opts_with_ignoring_script IRB.irb nil, @context end |