学习 Ruby(影印版)
学习 Ruby(影印版)
Michael Fitzgerald

由于网络开发框架Ruby on Rails的流行和大受欢迎,Ruby已经引起了很多Java和PHP开发人员的兴趣。但除了Rails之外,Ruby还有其他广泛的用途,而学习这些用法的最好方法就是动手尝试编写代码。在本书中,几乎每一页都可以找到代码例子,您可以仿照或者改写这些例子,生成您自己的代码。


· 介绍Ruby最重要的功能特性

· 示例说明如何使用条件语句以及如何使用Ruby字符串

· 涵盖正则表达式

· 解释如何使用Ruby的操作符、算术表达式、Math模块的函数、有理数等等

· 详细介绍Ruby数组和hash功能

· 讲解使用Ruby进行文件处理

· 对Ruby类和mixin模块的细节展开讨论,包括对面向对象编程的简要介绍

· 介绍XML处理、Tk工具包、RubyGems、反射机制(reflection)、RDoc、嵌入式Ruby、元编程(metaprogramming)、异常处理等内容

· 让您掌握Rails的基本知识,包括一个Rails的简单教程


Michael Fitzgerald是一位有20多年经验的程序员和作者,他认为Ruby是到目前为止他最喜爱的编程语言。Michael还是《Learning XSLT》《XML Hacks》《Ruby Pocket Reference》的作者,也是《XML Pocket Reference》的作者之一。以上提到的书籍均由O'Reilly出版。
  1. Preface
  2. 1. Ruby Basics
  3. Hello, Matz
  4. Interactive Ruby
  5. Resources
  6. Installing Ruby
  7. Permission Denied
  8. Associating File Types on Windows
  9. Review Questions
  10. 2. A Quick Tour of Ruby
  11. Ruby Is Object-Oriented
  12. Ruby's Reserved Words
  14. Variables
  15. Strings
  16. Numbers and Operators
  17. Conditional Statements
  18. Arrays and Hashes
  19. Methods
  20. Blocks
  21. Symbols
  22. Exception Handling
  23. Ruby Documentation
  24. Review Questions
  25. 3. Conditional Love
  26. The if Statement
  27. The case Statement
  28. The while Loop
  29. The loop Method
  30. The for loop
  31. Execution Before or After a Program
  32. Review Questions
  33. 4. Strings
  34. Creating Strings
  35. Concatenating Strings
  36. Accessing Strings
  37. Comparing Strings
  38. Manipulating Strings
  39. Case Conversion
  40. Managing Whitespace, etc.
  41. Incrementing Strings
  42. Converting Strings
  43. Regular Expressions
  44. 1.9 and Beyond
  45. Review Questions
  46. 5. Math
  47. Class Hierarchy and Included Modules
  48. Converting Numbers
  49. Basic Math Operations
  50. Ranges
  51. Inquiring About Numbers
  52. More Math Methods
  53. Math Functions
  54. Rational Numbers
  55. Prime Numbers
  56. Review Questions
  57. 6. Arrays
  58. Creating Arrays
  59. Accessing Elements
  60. Concatenation
  61. Set Operations
  62. Unique Elements
  63. Blow Your Stack
  64. Comparing Arrays
  65. Changing Elements
  66. Deleting Elements
  67. Arrays and Blocks
  68. Sorting Things and About Face
  69. Multidimensional Arrays
  70. 1.9 and Beyond
  71. Other Array Methods
  72. Review Questions
  73. 7. Hashes
  74. Creating Hashes
  75. Accessing Hashes
  76. Iterating over Hashes
  77. Changing Hashes
  78. Converting Hashes to Other Classes
  79. 1.9 and Beyond
  80. Other Hash Methods
  81. Review Questions
  82. 8. Working with Files
  83. Directories
  84. Creating a New File
  85. Opening an Existing File
  86. Deleting and Renaming Files
  87. File Inquiries
  88. Changing File Modes and Owner
  89. The IO Class
  90. Review Questions
  91. 9. Classes
  92. Defining the Class
  93. Instance Variables
  94. Accessors
  95. Class Variables
  96. Class Methods
  97. Inheritance
  98. Modules
  99. public, private, or protected
  100. Review Questions
  101. 10. More Fun with Ruby
  102. Formatting Output with sprintf
  103. Processing XML
  104. Date and Time
  105. Reflection
  106. Using Tk
  107. Metaprogramming
  108. RubyGems
  109. Exception Handling
  110. Creating Documentation with RDoc
  111. Embedded Ruby
  112. Review Questions
  113. 11. A Short Guide to Ruby on Rails
  114. Where Did Rails Come From?
  115. Why Rails?
  116. What Have Other Folks Done with Rails?
  117. Hosting Rails
  118. Installing Rails
  119. Learning Rails
  120. A Brief Tutorial
  121. Review Questions
  122. A. Ruby Reference
  123. B. Answers to Review Questions
  124. Glossary
  125. Index
书名:学习 Ruby(影印版)
作者:Michael Fitzgerald
原版书出版商:O'Reilly Media
Michael Fitzgerald
知名程序员、顾问、技术作家,为O’Reilly以及John Wiley & Sons编写过十余本技术图书,在O’Reilly Network上发表了大量文章。他曾是针对XML的RELAX NG模式语言委员会的成员。
The animals on the cover of Learning Ruby 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 pressureregulation 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.