Sha256: 50c21d70b62a0e17951eb3e4df70d523a10c2714a6f5a316c7d8e9142c7a97bb

Contents?: true

Size: 742 Bytes

Versions: 1

Compression:

Stored size: 742 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(client, object_data)
        elsif object_data["id"].match /^comment\..+/
          @items << Skydrive::Comment.new(client, object_data)
        end
      end
      @items
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
skydrive-1.2.0 lib/skydrive/collection.rb