Class: ActiveLrs::Xapi::StatementRef
- Inherits:
-
Object
- Object
- ActiveLrs::Xapi::StatementRef
- Defined in:
- lib/active_lrs/xapi/statement_ref.rb
Overview
Represents an xAPI StatementRef object.
A StatementRef allows one Statement to refer to another Statement by its id. This is useful for embedding or linking statements without duplicating all data. Typically used in the object property of a Statement.
Instance Attribute Summary collapse
-
#id ⇒ String
The ID of the referenced statement.
-
#object_type ⇒ String
The object type.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ void
constructor
Initializes a new StatementRef.
-
#to_h ⇒ Hash{String => String}
Converts the StatementRef into a hash suitable for use as the
objectof a Statement.
Constructor Details
#initialize(attributes = {}) ⇒ void
Initializes a new StatementRef.
26 27 28 29 |
# File 'lib/active_lrs/xapi/statement_ref.rb', line 26 def initialize(attributes = {}) @object_type = "StatementRef" self.id = attributes["id"] if attributes["id"] end |
Instance Attribute Details
#id ⇒ String
Returns The ID of the referenced statement.
18 19 20 |
# File 'lib/active_lrs/xapi/statement_ref.rb', line 18 def id @id end |
#object_type ⇒ String
Returns The object type. MUST be the literal string ‘“StatementRef”`.
15 16 17 |
# File 'lib/active_lrs/xapi/statement_ref.rb', line 15 def object_type @object_type end |
Instance Method Details
#to_h ⇒ Hash{String => String}
Converts the StatementRef into a hash suitable for use as the object of a Statement.
39 40 41 42 43 44 |
# File 'lib/active_lrs/xapi/statement_ref.rb', line 39 def to_h node = {} node["id"] = id if id node["objectType"] = object_type node end |