Sha256: 927fad2e01cc1f465db08dd384e07ea49e6d9dbc66380bedddd64f1487ad6cfe

Contents?: true

Size: 469 Bytes

Versions: 5

Compression:

Stored size: 469 Bytes

Contents

module FbGraph2
  class Collection < Array
    attr_reader :previous, :next, :total_count, :unread_count, :updated_time, :cursors

    def initialize(collection = nil)
      collection = case collection
      when Hash
        collection
      when Array
        {
          data:  collection,
          count: collection.size
        }
      else
        raise ArgumentError.new("Invalid collection")
      end
      replace Array(collection[:data])
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fb_graph2-0.0.4 lib/fb_graph2/collection.rb
fb_graph2-0.0.3 lib/fb_graph2/collection.rb
fb_graph2-0.0.2 lib/fb_graph2/collection.rb
fb_graph2-0.0.1 lib/fb_graph2/collection.rb
fb_graph2-0.0.0 lib/fb_graph2/collection.rb