Class: Smith::Workflow::Graph::Report
- Inherits:
-
Object
- Object
- Smith::Workflow::Graph::Report
- Defined in:
- lib/smith/workflow/graph/report.rb
Instance Attribute Summary collapse
-
#diagnostics ⇒ Object
readonly
Returns the value of attribute diagnostics.
-
#initial_state ⇒ Object
readonly
Returns the value of attribute initial_state.
-
#metrics ⇒ Object
readonly
Returns the value of attribute metrics.
-
#states ⇒ Object
readonly
Returns the value of attribute states.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#transitions ⇒ Object
readonly
Returns the value of attribute transitions.
-
#workflow_class ⇒ Object
readonly
Returns the value of attribute workflow_class.
Instance Method Summary collapse
- #errors ⇒ Object
-
#initialize(**attributes) ⇒ Report
constructor
A new instance of Report.
- #suggestions ⇒ Object
- #to_h ⇒ Object
- #valid? ⇒ Boolean
- #warnings ⇒ Object
Constructor Details
#initialize(**attributes) ⇒ Report
Returns a new instance of Report.
9 10 11 12 13 14 15 16 17 |
# File 'lib/smith/workflow/graph/report.rb', line 9 def initialize(**attributes) @status = attributes.fetch(:status) @workflow_class = attributes.fetch(:workflow_class) @initial_state = attributes.fetch(:initial_state) @states = attributes.fetch(:states) @transitions = attributes.fetch(:transitions) @diagnostics = attributes.fetch(:diagnostics) @metrics = attributes.fetch(:metrics) end |
Instance Attribute Details
#diagnostics ⇒ Object (readonly)
Returns the value of attribute diagnostics.
7 8 9 |
# File 'lib/smith/workflow/graph/report.rb', line 7 def diagnostics @diagnostics end |
#initial_state ⇒ Object (readonly)
Returns the value of attribute initial_state.
7 8 9 |
# File 'lib/smith/workflow/graph/report.rb', line 7 def initial_state @initial_state end |
#metrics ⇒ Object (readonly)
Returns the value of attribute metrics.
7 8 9 |
# File 'lib/smith/workflow/graph/report.rb', line 7 def metrics @metrics end |
#states ⇒ Object (readonly)
Returns the value of attribute states.
7 8 9 |
# File 'lib/smith/workflow/graph/report.rb', line 7 def states @states end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
7 8 9 |
# File 'lib/smith/workflow/graph/report.rb', line 7 def status @status end |
#transitions ⇒ Object (readonly)
Returns the value of attribute transitions.
7 8 9 |
# File 'lib/smith/workflow/graph/report.rb', line 7 def transitions @transitions end |
#workflow_class ⇒ Object (readonly)
Returns the value of attribute workflow_class.
7 8 9 |
# File 'lib/smith/workflow/graph/report.rb', line 7 def workflow_class @workflow_class end |
Instance Method Details
#errors ⇒ Object
23 24 25 |
# File 'lib/smith/workflow/graph/report.rb', line 23 def errors diagnostics.select { |diagnostic| diagnostic.severity == :error } end |
#suggestions ⇒ Object
31 32 33 |
# File 'lib/smith/workflow/graph/report.rb', line 31 def suggestions diagnostics.map(&:suggestion).compact.uniq end |
#to_h ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/smith/workflow/graph/report.rb', line 35 def to_h { status: status, workflow_class: workflow_class, initial_state: initial_state, states: states, transitions: transitions.map(&:to_h), diagnostics: diagnostics.map(&:to_h), suggestions: suggestions, metrics: metrics } end |
#valid? ⇒ Boolean
19 20 21 |
# File 'lib/smith/workflow/graph/report.rb', line 19 def valid? errors.empty? end |
#warnings ⇒ Object
27 28 29 |
# File 'lib/smith/workflow/graph/report.rb', line 27 def warnings diagnostics.select { |diagnostic| diagnostic.severity == :warning } end |