Sha256: b3529deda141a9f7a1ce5b3cba0f49258dc3d6fb0863fff0176a2cbea294129e

Contents?: true

Size: 739 Bytes

Versions: 7

Compression:

Stored size: 739 Bytes

Contents

module Skydrive

  # An object with an array of objects of multiple types
  class Collection
    attr_reader :client, :data
    def initialize client, data
      @client = client
      @data = data
    end

    # Additional type for the collection
    # @return [String]
    def type
      "collection"
    end

    # Array of items in the collection
    # @return [Array]
    def items
      @items = []
      @data.each do |object_data|
        if object_data["type"]
          @items << "Skydrive::#{object_data["type"].capitalize}".constantize.new(self, object_data)
        elsif object_data["id"].match /^comment\..+/
          @items << Skydrive::Comment.new(client, object_data)
        end
      end
      @items
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
skydrive-1.1.0 lib/skydrive/collection.rb
skydrive-1.0.0 lib/skydrive/collection.rb
skydrive-0.1.5 lib/skydrive/collection.rb
skydrive-0.1.4 lib/skydrive/collection.rb
skydrive-0.1.0 lib/skydrive/collection.rb
skydrive-0.0.2 lib/skydrive/collection.rb
skydrive-0.0.1 lib/skydrive/collection.rb