Class: Runbook::AirbrusshContext
- Inherits:
-
Object
- Object
- Runbook::AirbrusshContext
- Defined in:
- lib/runbook/airbrussh_context.rb
Instance Attribute Summary collapse
-
#current_task_name ⇒ Object
readonly
Returns the value of attribute current_task_name.
-
#history ⇒ Object
readonly
Returns the value of attribute history.
Instance Method Summary collapse
-
#initialize(config = Airbrussh.configuration) ⇒ AirbrusshContext
constructor
A new instance of AirbrusshContext.
- #position(command) ⇒ Object
- #register_new_command(command) ⇒ Object
- #set_current_task_name(task_name) ⇒ Object
Constructor Details
#initialize(config = Airbrussh.configuration) ⇒ AirbrusshContext
Returns a new instance of AirbrusshContext.
5 6 7 |
# File 'lib/runbook/airbrussh_context.rb', line 5 def initialize(config=Airbrussh.configuration) @history = [] end |
Instance Attribute Details
#current_task_name ⇒ Object (readonly)
Returns the value of attribute current_task_name.
3 4 5 |
# File 'lib/runbook/airbrussh_context.rb', line 3 def current_task_name @current_task_name end |
#history ⇒ Object (readonly)
Returns the value of attribute history.
3 4 5 |
# File 'lib/runbook/airbrussh_context.rb', line 3 def history @history end |
Instance Method Details
#position(command) ⇒ Object
16 17 18 |
# File 'lib/runbook/airbrussh_context.rb', line 16 def position(command) history.rindex(command.to_s) end |
#register_new_command(command) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/runbook/airbrussh_context.rb', line 9 def register_new_command(command) hist_entry = command.to_s first_execution = history.last != hist_entry history << hist_entry if first_execution first_execution end |
#set_current_task_name(task_name) ⇒ Object
20 21 22 23 |
# File 'lib/runbook/airbrussh_context.rb', line 20 def set_current_task_name(task_name) @current_task_name = task_name history.clear end |