Class: Talis::Feeds::Annotation
- Defined in:
- lib/talis/feeds/annotation.rb
Overview
Represents an annotation, for example, a video resource comment.
Instance Attribute Summary collapse
-
#annotated_by ⇒ Object
readonly
Returns the value of attribute annotated_by.
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#motivated_by ⇒ Object
readonly
Returns the value of attribute motivated_by.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
-
.create(opts) ⇒ Talis::Feeds::Annotation
Create a new annotation that is persisted.
Instance Method Summary collapse
-
#initialize(data, user: nil) ⇒ Annotation
constructor
Creates a new annotation object.
Methods inherited from Resource
Constructor Details
#initialize(data, user: nil) ⇒ Annotation
Creates a new annotation object. For internal use only, use create.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/talis/feeds/annotation.rb', line 16 def initialize(data, user: nil) # Symbolise all keys for consistency between what was provided # and what is returned. data = JSON.parse(JSON[data], symbolize_names: true) @id = data[:_id] @body = data[:hasBody] @target = data[:hasTarget].map { |target| underscore(target) } @annotated_by = data[:annotatedBy] @motivated_by = data[:motivatedBy] @expires_at = data[:expiresAt] @user = user end |
Instance Attribute Details
#annotated_by ⇒ Object (readonly)
Returns the value of attribute annotated_by.
6 7 8 |
# File 'lib/talis/feeds/annotation.rb', line 6 def annotated_by @annotated_by end |
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/talis/feeds/annotation.rb', line 6 def body @body end |
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
6 7 8 |
# File 'lib/talis/feeds/annotation.rb', line 6 def expires_at @expires_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/talis/feeds/annotation.rb', line 6 def id @id end |
#motivated_by ⇒ Object (readonly)
Returns the value of attribute motivated_by.
6 7 8 |
# File 'lib/talis/feeds/annotation.rb', line 6 def motivated_by @motivated_by end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
6 7 8 |
# File 'lib/talis/feeds/annotation.rb', line 6 def target @target end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
6 7 8 |
# File 'lib/talis/feeds/annotation.rb', line 6 def user @user end |
Class Method Details
.create(opts) ⇒ Talis::Feeds::Annotation
Create a new annotation that is persisted.
62 63 64 65 66 67 |
# File 'lib/talis/feeds/annotation.rb', line 62 def create(opts) validate_annotation opts new handle_response(post_annotation(opts)) rescue SocketError raise Talis::ServerCommunicationError end |