Class: TinCanApi::Attachment
- Inherits:
-
Object
- Object
- TinCanApi::Attachment
- Defined in:
- lib/tin_can_api/attachment.rb
Overview
Attachment Class
Instance Attribute Summary collapse
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#description ⇒ Object
Returns the value of attribute description.
-
#display ⇒ Object
Returns the value of attribute display.
-
#file_url ⇒ Object
Returns the value of attribute file_url.
-
#length ⇒ Object
Returns the value of attribute length.
-
#sha2 ⇒ Object
Returns the value of attribute sha2.
-
#usage_type ⇒ Object
Returns the value of attribute usage_type.
Instance Method Summary collapse
-
#initialize(options = {}, &block) ⇒ Attachment
constructor
A new instance of Attachment.
- #serialize(version) ⇒ Object
Constructor Details
#initialize(options = {}, &block) ⇒ Attachment
Returns a new instance of Attachment.
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 |
# File 'lib/tin_can_api/attachment.rb', line 9 def initialize(={}, &block) json = .fetch(:json, nil) if json attributes = JSON.parse(json) self.usage_type = attributes['usageType'] if attributes['usageType'] self.display = attributes['display'] if attributes['display'] self.description = attributes['description'] if attributes['description'] self.content_type = attributes['contentType'] if attributes['contentType'] self.length = attributes['length'] if attributes['length'] self.sha2 = attributes['sha2'] if attributes['sha2'] self.file_url = attributes['fileUrl'] if attributes['fileUrl'] else self.usage_type = .fetch(:usage_type, nil) self.display = .fetch(:display, nil) self.description = .fetch(:description, nil) self.content_type = .fetch(:content_type, nil) self.length = .fetch(:length, nil) self.sha2 = .fetch(:sha2, nil) self.file_url = .fetch(:file_url, nil) if block_given? block[self] end end end |
Instance Attribute Details
#content_type ⇒ Object
Returns the value of attribute content_type.
6 7 8 |
# File 'lib/tin_can_api/attachment.rb', line 6 def content_type @content_type end |
#description ⇒ Object
Returns the value of attribute description.
6 7 8 |
# File 'lib/tin_can_api/attachment.rb', line 6 def description @description end |
#display ⇒ Object
Returns the value of attribute display.
6 7 8 |
# File 'lib/tin_can_api/attachment.rb', line 6 def display @display end |
#file_url ⇒ Object
Returns the value of attribute file_url.
7 8 9 |
# File 'lib/tin_can_api/attachment.rb', line 7 def file_url @file_url end |
#length ⇒ Object
Returns the value of attribute length.
6 7 8 |
# File 'lib/tin_can_api/attachment.rb', line 6 def length @length end |
#sha2 ⇒ Object
Returns the value of attribute sha2.
6 7 8 |
# File 'lib/tin_can_api/attachment.rb', line 6 def sha2 @sha2 end |
#usage_type ⇒ Object
Returns the value of attribute usage_type.
7 8 9 |
# File 'lib/tin_can_api/attachment.rb', line 7 def usage_type @usage_type end |
Instance Method Details
#serialize(version) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/tin_can_api/attachment.rb', line 51 def serialize(version) node = {} node['usageType'] = usage_type.to_s if usage_type node['display'] = display if display node['description'] = description if description node['contentType'] = content_type if content_type node['length'] = length if length node['sha2'] = sha2 if sha2 node['fileUrl'] = file_url.to_s if file_url node end |