Class: ActiveLrs::Xapi::Score
- Inherits:
-
Object
- Object
- ActiveLrs::Xapi::Score
- Defined in:
- lib/active_lrs/xapi/score.rb
Overview
Represents an xAPI Score object, which can include normalized (scaled), raw, minimum, and maximum values.
This maps directly to the score property inside an xAPI Result object.
Instance Attribute Summary collapse
-
#max ⇒ Numeric?
The maximum possible score.
-
#min ⇒ Numeric?
The minimum possible score.
-
#raw ⇒ Numeric?
The raw score as reported.
-
#scaled ⇒ Numeric?
The normalized score (0.0–1.0 range, typically).
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ void
constructor
Initializes a new Score instance with optional attributes.
-
#to_h ⇒ Hash{String => Numeric}
Converts the Score object into a hash representation suitable for serialization in an xAPI Statement.
Constructor Details
#initialize(attributes = {}) ⇒ void
Initializes a new Score instance with optional attributes.
35 36 37 38 39 40 |
# File 'lib/active_lrs/xapi/score.rb', line 35 def initialize(attributes = {}) self.scaled = attributes["scaled"] if attributes["scaled"] self.raw = attributes["raw"] if attributes["raw"] self.min = attributes["min"] if attributes["min"] self.max = attributes["max"] if attributes["max"] end |
Instance Attribute Details
#max ⇒ Numeric?
Returns the maximum possible score.
24 25 26 |
# File 'lib/active_lrs/xapi/score.rb', line 24 def max @max end |
#min ⇒ Numeric?
Returns the minimum possible score.
21 22 23 |
# File 'lib/active_lrs/xapi/score.rb', line 21 def min @min end |
#raw ⇒ Numeric?
Returns the raw score as reported.
18 19 20 |
# File 'lib/active_lrs/xapi/score.rb', line 18 def raw @raw end |
#scaled ⇒ Numeric?
Returns the normalized score (0.0–1.0 range, typically).
15 16 17 |
# File 'lib/active_lrs/xapi/score.rb', line 15 def scaled @scaled end |
Instance Method Details
#to_h ⇒ Hash{String => Numeric}
Converts the Score object into a hash representation suitable for serialization in an xAPI Statement.
51 52 53 54 55 56 57 58 |
# File 'lib/active_lrs/xapi/score.rb', line 51 def to_h node = {} node["scaled"] = scaled if scaled node["raw"] = raw if raw node["min"] = min if min node["max"] = max if max node end |