Class: TinCanApi::Context
- Inherits:
-
Object
- Object
- TinCanApi::Context
- Defined in:
- lib/tin_can_api/context.rb
Overview
Context Class Description
Instance Attribute Summary collapse
-
#context_activities ⇒ Object
Returns the value of attribute context_activities.
-
#extensions ⇒ Object
Returns the value of attribute extensions.
-
#instructor ⇒ Object
Returns the value of attribute instructor.
-
#language ⇒ Object
Returns the value of attribute language.
-
#platform ⇒ Object
Returns the value of attribute platform.
-
#registration ⇒ Object
Returns the value of attribute registration.
-
#revision ⇒ Object
Returns the value of attribute revision.
-
#statement ⇒ Object
Returns the value of attribute statement.
-
#team ⇒ Object
Returns the value of attribute team.
Instance Method Summary collapse
-
#initialize(options = {}, &block) ⇒ Context
constructor
A new instance of Context.
- #serialize(version) ⇒ Object
Constructor Details
#initialize(options = {}, &block) ⇒ Context
Returns a new instance of Context.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/tin_can_api/context.rb', line 9 def initialize(={}, &block) json = .fetch(:json, nil) if json attributes = JSON.parse(json) self.registration = attributes['registration'] if attributes['registration'] self.instructor = TinCanApi::Agent.new(json: attributes['instructor'].to_json) if attributes['instructor'] self.team = TinCanApi::Agent.new(json: attributes['team'].to_json) if attributes['team'] self.context_activities = TinCanApi::ContextActivities.new(json: attributes['contextActivities'].to_json) if attributes['contextActivities'] self.revision = attributes['revision'] if attributes['revision'] self.platform = attributes['platform'] if attributes['platform'] self.language = attributes['language'] if attributes['language'] self.statement = TinCanApi::StatementRef.new(json: attributes['statement'].to_json) if attributes['statement'] self.extensions = attributes['extensions'] if attributes['extensions'] else self.registration = .fetch(:registration, nil) self.instructor = .fetch(:instructor, nil) self.team = .fetch(:team, nil) self.context_activities = .fetch(:context_activities, nil) self.revision = .fetch(:revision, nil) self.platform = .fetch(:platform, nil) self.language = .fetch(:language, nil) self.extensions = .fetch(:extensions, nil) if block_given? block[self] end end end |
Instance Attribute Details
#context_activities ⇒ Object
Returns the value of attribute context_activities.
6 7 8 |
# File 'lib/tin_can_api/context.rb', line 6 def context_activities @context_activities end |
#extensions ⇒ Object
Returns the value of attribute extensions.
7 8 9 |
# File 'lib/tin_can_api/context.rb', line 7 def extensions @extensions end |
#instructor ⇒ Object
Returns the value of attribute instructor.
6 7 8 |
# File 'lib/tin_can_api/context.rb', line 6 def instructor @instructor end |
#language ⇒ Object
Returns the value of attribute language.
7 8 9 |
# File 'lib/tin_can_api/context.rb', line 7 def language @language end |
#platform ⇒ Object
Returns the value of attribute platform.
7 8 9 |
# File 'lib/tin_can_api/context.rb', line 7 def platform @platform end |
#registration ⇒ Object
Returns the value of attribute registration.
6 7 8 |
# File 'lib/tin_can_api/context.rb', line 6 def registration @registration end |
#revision ⇒ Object
Returns the value of attribute revision.
6 7 8 |
# File 'lib/tin_can_api/context.rb', line 6 def revision @revision end |
#statement ⇒ Object
Returns the value of attribute statement.
7 8 9 |
# File 'lib/tin_can_api/context.rb', line 7 def statement @statement end |
#team ⇒ Object
Returns the value of attribute team.
6 7 8 |
# File 'lib/tin_can_api/context.rb', line 6 def team @team end |
Instance Method Details
#serialize(version) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/tin_can_api/context.rb', line 38 def serialize(version) node = {} node['registration'] = registration if registration node['instructor'] = instructor.serialize(version) if instructor node['team'] = team.serialize(version) if team node['contextActivities'] = context_activities.serialize(version) if context_activities node['revision'] = revision if revision node['platform'] = platform if platform node['language'] = language if language node['statement'] = statement.serialize(version) if statement node['extensions'] = extensions if extensions node end |