class Quby::Answers::Entities::Outcome

Attributes

actions[RW]

@return [Hash]

completion[RW]

@return [Hash]

generated_at[RW]

@return [Time]

scores[RW]

@return [Hash]

Public Class Methods

new(scores: {}, actions: {}, completion: {}, generated_at: nil) click to toggle source
# 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

Public Instance Methods

action() click to toggle source
# 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