Class: ActiveLrs::Xapi::Agent
- Inherits:
-
Object
- Object
- ActiveLrs::Xapi::Agent
- Defined in:
- lib/active_lrs/xapi/agent.rb
Overview
Represents an xAPI Agent object.
An Agent identifies an individual (person) associated with an xAPI Statement. An Agent can be uniquely identified using one of the Inverse Functional Identifier (IFI) fields: mbox, mbox_sha1sum, openid, or account.
This class is intended for use as the actor or object property within an xAPI Statement.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#account ⇒ AgentAccount?
An account object uniquely identifying the Agent within a given system.
-
#mbox ⇒ String?
A “mailto:” IRI identifying the Agent’s email address.
-
#mbox_sha1_sum ⇒ String?
The SHA1 hash of a “mailto:” IRI.
-
#name ⇒ String?
The full name of the Agent (human-readable).
-
#object_type ⇒ String
The object type.
-
#open_id ⇒ String?
An OpenID URI that uniquely identifies the Agent.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ void
constructor
Initializes a new Agent instance with optional attributes.
-
#to_h ⇒ Hash{String => String, Hash}
Converts the Agent object into a hash representation suitable for serialization in an xAPI Statement.
Constructor Details
#initialize(attributes = {}) ⇒ void
Initializes a new Agent instance with optional attributes.
48 49 50 51 52 53 54 55 |
# File 'lib/active_lrs/xapi/agent.rb', line 48 def initialize(attributes = {}) @object_type = "Agent" self.name = attributes["name"] if attributes["name"] self.mbox = attributes["mbox"] if attributes["mbox"] self.mbox_sha1_sum = attributes["mbox_sha1sum"] if attributes["mbox_sha1sum"] self.open_id = attributes["openid"] if attributes["openid"] self.account = Xapi::AgentAccount.new(attributes["account"]) if attributes["account"] end |
Instance Attribute Details
#account ⇒ AgentAccount?
Returns An account object uniquely identifying the Agent within a given system.
32 33 34 |
# File 'lib/active_lrs/xapi/agent.rb', line 32 def account @account end |
#mbox ⇒ String?
Returns A “mailto:” IRI identifying the Agent’s email address.
22 23 24 |
# File 'lib/active_lrs/xapi/agent.rb', line 22 def mbox @mbox end |
#mbox_sha1_sum ⇒ String?
Returns The SHA1 hash of a “mailto:” IRI.
25 26 27 |
# File 'lib/active_lrs/xapi/agent.rb', line 25 def mbox_sha1_sum @mbox_sha1_sum end |
#name ⇒ String?
Returns The full name of the Agent (human-readable).
19 20 21 |
# File 'lib/active_lrs/xapi/agent.rb', line 19 def name @name end |
#object_type ⇒ String
Returns The object type. MUST be the literal string ‘“Agent”`.
35 36 37 |
# File 'lib/active_lrs/xapi/agent.rb', line 35 def object_type @object_type end |
#open_id ⇒ String?
Returns An OpenID URI that uniquely identifies the Agent.
28 29 30 |
# File 'lib/active_lrs/xapi/agent.rb', line 28 def open_id @open_id end |
Instance Method Details
#to_h ⇒ Hash{String => String, Hash}
Converts the Agent object into a hash representation suitable for serialization in an xAPI Statement.
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/active_lrs/xapi/agent.rb', line 74 def to_h node = {} node["objectType"] = object_type node["name"] = name if name node["mbox"] = mbox if mbox node["mbox_sha1sum"] = mbox_sha1_sum if mbox_sha1_sum node["openid"] = open_id if open_id node["account"] = account.to_h if account node end |