Fctions

TwitterFacebook
Get flash to fully experience Pearltrees
http://www.techotopia.com/index.php/Advanced_Ruby_Arrays

Advanced Ruby Arrays - Techotopia

From Techotopia Purchase and download the PDF and ePub versions of this Ruby eBook for only $8.99 days1 = ["Mon", "Tue", "Wed"] days2 = ["Thu", "Fri", "Sat", "Sun"] days = days1 + days2 => ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] Ruby's support for array manipulation goes beyond that offered by many other scripting languages. One area where this is particularly true involves the ability to create new arrays based on the union, intersection and difference of two arrays. These features are provided via the following set operation symbols:

Working with Files in Ruby - Techotopia

http://www.techotopia.com/index.php/Working_with_Files_in_Ruby In the previous chapter we looked at how to work with directories. This chapter will look in detail at how to create, open and read and write to files in Ruby. We will then learn how to delete and rename files. [ edit ] Creating a New File with Ruby New files are created in Ruby using the new method of the File class. The new method accepts two arguments, the first being the name of the file to be created and the second being the mode in which the file is to opened.
Vous pouvez créer un tableau en énumérant divers éléments entre des crochets ( [ ] ), en les séparant par des virgules. Les tableaux de ruby peuvent contenir des objets de divers types. Un tableau associatif a des éléments auxquels on accède non plus par des indices numériques croissant séquentiellement, mais par des clés qui peuvent avoir n’importe quelle valeur. Ce type de tableau est parfois appelé hash ou dictionnaire; dans le monde ruby, on préfère le mot hash. Un hash peut être construit par des paires de valeurs entre accolades ( { } ).

Tableaux

http://www.rubyfrance.org/documentations/les-bases/le-guide-de-lutilisateur/tableaux/

Class: ActiveRecord::Base

Active Record objects don’t specify their attributes directly, but rather infer them from the table definition with which they’re linked. Adding, removing, and changing attributes and their type is done directly in the database. Any change is instantly reflected in the Active Record objects. The mapping that binds a given Active Record class to a certain database table will happen automatically in most common cases, but can be overwritten for the uncommon ones. Active Records accept constructor parameters either in a hash or as a block. The hash method is especially useful when you’re receiving the data from somewhere else, like an HTTP request. http://api.rubyonrails.org/classes/ActiveRecord/Base.html
Directory

Hash

Factory