Class: Flickrie::Collection

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Instance Attribute Details

#current_pageObject (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_pageObject (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_entriesObject (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_pagesObject (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