Class: Skydrive::Collection
- Inherits:
-
Object
- Object
- Skydrive::Collection
- Defined in:
- lib/skydrive/collection.rb
Overview
An object with an array of objects of multiple types
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(client, data) ⇒ Collection
constructor
A new instance of Collection.
-
#items ⇒ Array
Array of items in the collection.
-
#type ⇒ String
Additional type for the collection.
Constructor Details
#initialize(client, data) ⇒ Collection
Returns a new instance of Collection.
6 7 8 9 |
# File 'lib/skydrive/collection.rb', line 6 def initialize client, data @client = client @data = data end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/skydrive/collection.rb', line 5 def client @client end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/skydrive/collection.rb', line 5 def data @data end |
Instance Method Details
#items ⇒ Array
Array of items in the collection
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/skydrive/collection.rb', line 19 def items @items = [] @data.each do |object_data| if object_data["type"] @items << "Skydrive::#{object_data["type"].capitalize}".constantize.new(client, object_data) elsif object_data["id"].match /^comment\..+/ @items << Skydrive::Comment.new(client, object_data) end end @items end |
#type ⇒ String
Additional type for the collection
13 14 15 |
# File 'lib/skydrive/collection.rb', line 13 def type "collection" end |