Class: Bcome::Interactive::Session
- Inherits:
-
Object
- Object
- Bcome::Interactive::Session
- Defined in:
- lib/objects/interactive/session.rb
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#responses ⇒ Object
readonly
Returns the value of attribute responses.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(node, item_klass, init_data) ⇒ Session
constructor
A new instance of Session.
- #start ⇒ Object
- #start_item ⇒ Object
Constructor Details
#initialize(node, item_klass, init_data) ⇒ Session
Returns a new instance of Session.
29 30 31 32 33 34 |
# File 'lib/objects/interactive/session.rb', line 29 def initialize(node, item_klass, init_data) @item_klass = item_klass @node = node @responses = {} @init_data = init_data end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
27 28 29 |
# File 'lib/objects/interactive/session.rb', line 27 def node @node end |
#responses ⇒ Object (readonly)
Returns the value of attribute responses.
27 28 29 |
# File 'lib/objects/interactive/session.rb', line 27 def responses @responses end |
Class Method Details
.run(node, session_type, init_data = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/objects/interactive/session.rb', line 4 def run(node, session_type, init_data = {}) = "\ninteractive session ended\n".informational begin session = ::Bcome::Interactive::Session.new(node, session_type_to_klass[session_type], init_data) session.start rescue ::Bcome::Exception::InteractiveSessionHalt => e puts rescue ::Bcome::Exception::CouldNotInitiateSshConnection => e puts 'Caught connection error #2' puts e..error rescue ::IRB::Abort puts end end |
.session_type_to_klass ⇒ Object
19 20 21 22 23 24 |
# File 'lib/objects/interactive/session.rb', line 19 def session_type_to_klass { interactive_ssh: ::Bcome::Interactive::SessionItem::TransparentSsh, capture_input: ::Bcome::Interactive::SessionItem::CaptureInput } end |
Instance Method Details
#start ⇒ Object
36 37 38 39 |
# File 'lib/objects/interactive/session.rb', line 36 def start print start_item. if start_item. start_item.do end |
#start_item ⇒ Object
41 42 43 |
# File 'lib/objects/interactive/session.rb', line 41 def start_item @start_item ||= @item_klass.new(self, @init_data) end |