entries/to_a methods

The entries/to_a methods take an enumerable collection and return it in array form.

Number List

@numbers = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8]

# all numbers:

Pet Inventory

# leg counts for all pets:

# leg totals for each pet type, if all pets have 100 in stock:
@inventory.entries(:quantity => 100).map{|pet| pet.legs * pet.quantity}

Pokey Things

# all pokey things:

Heroku Log File

# all heroku requests:

# all heroku requests in simple format:

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>