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
- #show_welcome ⇒ Object
- #spawn_into_console_for_context ⇒ Object
Constructor Details
#initialize ⇒ Workspace
Returns a new instance of Workspace.
9 10 11 12 13 |
# File 'lib/objects/workspace.rb', line 9 def initialize @context = nil @console_set = false @estate = nil end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
6 7 8 |
# File 'lib/objects/workspace.rb', line 6 def context @context end |
#estate ⇒ Object (readonly)
Returns the value of attribute estate.
7 8 9 |
# File 'lib/objects/workspace.rb', line 7 def estate @estate end |
Instance Method Details
#console_set! ⇒ Object
39 40 41 |
# File 'lib/objects/workspace.rb', line 39 def console_set! @console_set = true end |
#console_set? ⇒ Boolean
43 44 45 |
# File 'lib/objects/workspace.rb', line 43 def console_set? @console_set end |
#default_prompt ⇒ Object
63 64 65 |
# File 'lib/objects/workspace.rb', line 63 def default_prompt 'bcome' end |
#has_context? ⇒ Boolean
55 56 57 |
# File 'lib/objects/workspace.rb', line 55 def has_context? !context.nil? end |
#irb_prompt ⇒ Object
59 60 61 |
# File 'lib/objects/workspace.rb', line 59 def irb_prompt @context ? @context. : default_prompt end |
#object_is_current_context?(object) ⇒ Boolean
47 48 49 |
# File 'lib/objects/workspace.rb', line 47 def object_is_current_context?(object) @context == object end |
#set(params) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/objects/workspace.rb', line 15 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] show_welcome if params[:show_welcome] spawn_into_console_for_context nil end |
#show_welcome ⇒ Object
32 33 34 35 36 37 |
# File 'lib/objects/workspace.rb', line 32 def show_welcome puts "\n\n" puts "Welcome to bcome v#{::Bcome::Version.release}".bc_yellow puts "\nType\s" + 'menu'.underline + "\sfor a command list, or\s" + 'registry'.underline + "\sfor your custom tasks." puts "\n\n" end |
#spawn_into_console_for_context ⇒ Object
51 52 53 |
# File 'lib/objects/workspace.rb', line 51 def spawn_into_console_for_context ::IRB.start_session(self, @context) end |