Updated for Ruby 2.2, this handy reference offers brief yet clear explanations of Ruby’s core elements—from operators to blocks to documentation creation—and highlights the key features you may work with every day. Need to know the correct syntax for a conditional? Forgot the name of that String method? This book is organized to help you find the facts fast.
Ruby Pocket Reference, 2nd Edition is ideal for experienced programmers who are new to Ruby. Whether you’ve come to Ruby because of Rails, or you want to take advantage of this clean, powerful, and expressive language for other applications, this reference will help you easily pinpoint the information you need.
You’ll find detailed reference material for:
Keywords, operators, comments, numbers, and symbols
Variables, pre-defined global variables, and regular expressions
Conditional statements, method use, classes, and exception handling
Methods for the BasicObject, Object, Kernel, String, Array, and Hash classes
Michael Fitzgerald is an author, coder, and novelist who has written over 20 books. He is the author of O’Reilly’s Learning Ruby, Learning XSLT, and XML Hacks, and co-author on the XML Pocket Reference.
The animals on the cover of Ruby Pocket Reference are giraffes (Giraffa camelopardalis), the tallest of all land animals. A giraffe can reach 16 to 18 feet in height and weigh up to 3,000 pounds. Its species name, camelopardalis, is derived from an early Roman name, which described the giraffe as resembling both a camel and a leopard. The spots that cover its body act as camouflage in the African savanna. Its long neck and tough, prehensile tongue allow it to feed in treetops, consuming about 140 pounds of leaves and twigs daily. And its complex cardiovascular system and 24-pound heart regulate circulation throughout its tremendous body: in the upper neck, a pressure-regulation system prevents excess blood flow to the brain when the giraffe lowers its head to drink, while thick sheaths of skin on the lower legs maintain high extravascular pressure to compensate for the weight of the fluid pressing down on them.
Giraffes travel in herds comprised of about a dozen females, one or two males, and their young. Other males may travel alone, in pairs, or in bachelor herds. Male giraffes determine female fertility by tasting the female's urine to detect estrus. Yet sexual relations in male giraffes are most frequently homosexual: the proportion of same-sex courtships varies between 30 and 75 percent. Among females, homosexual mounting appears to comprise only 1 percent of all incidents. Gestation lasts between 14 and 15 months, after which a single calf is born. Only 25 to 50 percent of calves reach adulthood, as the giraffe's predators—including lions, leopards, hyenas, and African wild dogs—mainly prey on young.
Giraffes use their long necks and keen sense of smell, hearing, and eyesight to guard against attacks. They can reach speeds of up to 30 miles per hour and fight off predators using their muscular hind legs. A single kick from an adult giraffe can shatter a lion's skull. Giraffes were once hunted for their skin and tail but are currently a protected species.