Class: Quby::Answers::Entities::Score
- Inherits:
-
Object
- Object
- Quby::Answers::Entities::Score
- Defined in:
- lib/quby/answers/entities/score.rb
Overview
Score instances enhance answer#scores hash results with score schema information. It also presents the subscores as Subscore objects.
Instance Attribute Summary collapse
-
#score_schema ⇒ Object
Returns the value of attribute score_schema.
-
#subscores ⇒ Object
Returns the value of attribute subscores.
Instance Method Summary collapse
- #error ⇒ Object
-
#initialize(score_schema:, score_hash:) ⇒ Score
constructor
A new instance of Score.
- #initialize_subscores ⇒ Object
- #referenced_values ⇒ Object
Constructor Details
#initialize(score_schema:, score_hash:) ⇒ Score
Returns a new instance of Score.
20 21 22 23 24 |
# 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 |
Instance Attribute Details
#score_schema ⇒ Object
Returns the value of attribute score_schema.
8 9 10 |
# File 'lib/quby/answers/entities/score.rb', line 8 def score_schema @score_schema end |
#subscores ⇒ Object
Returns the value of attribute subscores.
9 10 11 |
# File 'lib/quby/answers/entities/score.rb', line 9 def subscores @subscores end |
Instance Method Details
#error ⇒ Object
36 37 38 39 40 41 42 |
# 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 ⇒ Object
26 27 28 29 30 |
# 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 ⇒ Object
32 33 34 |
# File 'lib/quby/answers/entities/score.rb', line 32 def referenced_values @score_hash[:referenced_values] end |