Class: Flickrie::Collection
- Inherits:
-
Object
- Object
- Flickrie::Collection
- Defined in:
- lib/flickrie/collection.rb
Overview
You can think of this as a richer Array. It defines some pagination attributes (you can even use it with will_paginate, see pagination), and some other useful methods.
Instance Attribute Summary collapse
-
#current_page ⇒ Object
readonly
Returns the value of attribute current_page.
-
#per_page ⇒ Object
readonly
Returns the value of attribute per_page.
-
#total_entries ⇒ Object
readonly
Returns the value of attribute total_entries.
-
#total_pages ⇒ Object
readonly
Returns the value of attribute total_pages.
Instance Method Summary collapse
-
#find(id = nil) ⇒ Object
Finds an object by ID (just like ActiveRecord does).
Instance Attribute Details
#current_page ⇒ Object (readonly)
Returns the value of attribute current_page.
1 2 3 |
# File 'lib/flickrie/collection.rb', line 1 def current_page @current_page end |
#per_page ⇒ Object (readonly)
Returns the value of attribute per_page.
1 2 3 |
# File 'lib/flickrie/collection.rb', line 1 def per_page @per_page end |
#total_entries ⇒ Object (readonly)
Returns the value of attribute total_entries.
1 2 3 |
# File 'lib/flickrie/collection.rb', line 1 def total_entries @total_entries end |
#total_pages ⇒ Object (readonly)
Returns the value of attribute total_pages.
1 2 3 |
# File 'lib/flickrie/collection.rb', line 1 def total_pages @total_pages end |
Instance Method Details
#find(id = nil) ⇒ Object
Finds an object by ID (just like ActiveRecord does). This is just a shorthand for
find { |object| object.id == id }
38 39 40 41 42 43 44 |
# File 'lib/flickrie/collection.rb', line 38 def find(id = nil) if block_given? super else super() { |object| object.id == id.to_s } end end |