class Quby::Answers::Entities::Score

Score instances enhance answer#scores hash results with score schema information. It also presents the subscores as Subscore objects.

Attributes

score_schema[RW]
subscores[RW]

Public Class Methods

new(score_schema:, score_hash:) click to toggle source
# File lib/quby/answers/entities/score.rb, line 20
def initialize(score_schema:, score_hash:)
  self.score_schema = score_schema
  @score_hash = score_hash
  initialize_subscores
end

Public Instance Methods

error() click to toggle source
# File lib/quby/answers/entities/score.rb, line 36
def error
  if @score_hash.has_key?(:exception)
    @score_hash.slice(:backtrace, :exception)
  else
    nil
  end
end
initialize_subscores() click to toggle source
# File lib/quby/answers/entities/score.rb, line 26
def initialize_subscores
  self.subscores = subscore_schemas.map do |subschema|
    [subschema.key, Entities::Subscore.new(subschema: subschema, score_hash: @score_hash)]
  end.to_h.with_indifferent_access
end
referenced_values() click to toggle source
# File lib/quby/answers/entities/score.rb, line 32
def referenced_values
  @score_hash[:referenced_values]
end