Class: Tapyrus::StepResult
- Inherits:
-
Object
- Object
- Tapyrus::StepResult
- Defined in:
- lib/tapyrus/script/debugger.rb
Constant Summary collapse
- STATUS_RUNNING =
"running"
- STATUS_HALT =
"halt"
- STATUS_FINISHED =
"finished"
- STATUSES =
[STATUS_RUNNING, STATUS_HALT, STATUS_FINISHED]
Instance Attribute Summary collapse
-
#current_stack ⇒ Object
readonly
Returns the value of attribute current_stack.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
- .error(current_stack: [], error:, message: nil) ⇒ Object
- .finished(current_stack: []) ⇒ Object
- .success(current_stack: [], message: nil) ⇒ Object
Instance Method Summary collapse
- #finished? ⇒ Boolean
- #halt? ⇒ Boolean
-
#initialize(status, current_stack: [], message: nil, error: nil) ⇒ StepResult
constructor
A new instance of StepResult.
- #print_result ⇒ Object
- #stack_table ⇒ Object
Constructor Details
#initialize(status, current_stack: [], message: nil, error: nil) ⇒ StepResult
Returns a new instance of StepResult.
114 115 116 117 118 119 120 |
# File 'lib/tapyrus/script/debugger.rb', line 114 def initialize(status, current_stack: [], message: nil, error: nil) raise ArgumentError, "Unsupported status specified." unless STATUSES.include?(status) @status = status @current_stack = current_stack @error = error @message = end |
Instance Attribute Details
#current_stack ⇒ Object (readonly)
Returns the value of attribute current_stack.
106 107 108 |
# File 'lib/tapyrus/script/debugger.rb', line 106 def current_stack @current_stack end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
108 109 110 |
# File 'lib/tapyrus/script/debugger.rb', line 108 def error @error end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
107 108 109 |
# File 'lib/tapyrus/script/debugger.rb', line 107 def @message end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
105 106 107 |
# File 'lib/tapyrus/script/debugger.rb', line 105 def status @status end |
Class Method Details
.error(current_stack: [], error:, message: nil) ⇒ Object
122 123 124 |
# File 'lib/tapyrus/script/debugger.rb', line 122 def self.error(current_stack: [], error:, message: nil) StepResult.new(STATUS_HALT, current_stack: current_stack, error: error, message: ) end |
.finished(current_stack: []) ⇒ Object
130 131 132 |
# File 'lib/tapyrus/script/debugger.rb', line 130 def self.finished(current_stack: []) StepResult.new(STATUS_FINISHED, current_stack: current_stack) end |
.success(current_stack: [], message: nil) ⇒ Object
126 127 128 |
# File 'lib/tapyrus/script/debugger.rb', line 126 def self.success(current_stack: [], message: nil) StepResult.new(STATUS_RUNNING, current_stack: current_stack, message: ) end |
Instance Method Details
#finished? ⇒ Boolean
138 139 140 |
# File 'lib/tapyrus/script/debugger.rb', line 138 def finished? status == STATUS_FINISHED end |
#halt? ⇒ Boolean
134 135 136 |
# File 'lib/tapyrus/script/debugger.rb', line 134 def halt? status == STATUS_HALT end |
#print_result ⇒ Object
147 148 149 150 |
# File 'lib/tapyrus/script/debugger.rb', line 147 def print_result puts if puts stack_table end |
#stack_table ⇒ Object
142 143 144 145 |
# File 'lib/tapyrus/script/debugger.rb', line 142 def stack_table rows = current_stack.map { |s| [s] }.reverse Terminal::Table.new(title: "Current Stack", rows: rows) end |