Class: FbGraph::Collection
- Inherits:
-
Array
- Object
- Array
- FbGraph::Collection
- Defined in:
- lib/fb_graph/collection.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#next ⇒ Object
readonly
Returns the value of attribute next.
-
#previous ⇒ Object
readonly
Returns the value of attribute previous.
-
#total_count ⇒ Object
readonly
Returns the value of attribute total_count.
Instance Method Summary collapse
-
#initialize(collection = nil) ⇒ Collection
constructor
A new instance of Collection.
Constructor Details
#initialize(collection = nil) ⇒ Collection
Returns a new instance of Collection.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fb_graph/collection.rb', line 5 def initialize(collection = nil) collection = case collection when Array {:data => collection, :count => collection.size} when Hash collection[:data] ||= [] collection when nil collection = {:data => [], :count => 0} else raise "Invalid collection" end result = replace(collection[:data]) @total_count = collection[:count] @previous, @next = {}, {} if (paging = collection[:paging]) if paging[:previous] @previous = fetch_params(paging[:previous]) end if paging[:next] @next = fetch_params(paging[:next]) end end end |
Instance Attribute Details
#next ⇒ Object (readonly)
Returns the value of attribute next.
3 4 5 |
# File 'lib/fb_graph/collection.rb', line 3 def next @next end |
#previous ⇒ Object (readonly)
Returns the value of attribute previous.
3 4 5 |
# File 'lib/fb_graph/collection.rb', line 3 def previous @previous end |
#total_count ⇒ Object (readonly)
Returns the value of attribute total_count.
3 4 5 |
# File 'lib/fb_graph/collection.rb', line 3 def total_count @total_count end |