Class: Quby::Answers::Entities::Outcome
- Inherits:
-
Object
- Object
- Quby::Answers::Entities::Outcome
- Defined in:
- lib/quby/answers/entities/outcome.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #action ⇒ Object
-
#initialize(scores: {}, actions: {}, completion: {}, generated_at: nil) ⇒ Outcome
constructor
A new instance of Outcome.
Constructor Details
#initialize(scores: {}, actions: {}, completion: {}, generated_at: nil) ⇒ Outcome
Returns a new instance of Outcome.
19 20 21 22 23 24 |
# File 'lib/quby/answers/entities/outcome.rb', line 19 def initialize(scores: {}, actions: {}, completion: {}, generated_at: nil) self.scores = scores self.actions = actions self.completion = completion self.generated_at = generated_at end |
Instance Attribute Details
#actions ⇒ Hash
11 12 13 |
# File 'lib/quby/answers/entities/outcome.rb', line 11 def actions @actions end |
#completion ⇒ Hash
14 15 16 |
# File 'lib/quby/answers/entities/outcome.rb', line 14 def completion @completion end |
#generated_at ⇒ Time
17 18 19 |
# File 'lib/quby/answers/entities/outcome.rb', line 17 def generated_at @generated_at end |
#scores ⇒ Hash
8 9 10 |
# File 'lib/quby/answers/entities/outcome.rb', line 8 def scores @scores end |
Instance Method Details
#action ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/quby/answers/entities/outcome.rb', line 34 def action alarm_scores = scores.select { |key, value| value["status"].to_s == "alarm" } alarm_answers = actions[:alarm] || [] attention_scores = scores.select { |key, value| value["status"].to_s == "attention" } attention_answers = actions[:attention] || [] return :alarm if alarm_scores.any? || alarm_answers.any? return :attention if attention_scores.any? || attention_answers.any? nil end |