Ruby 袖珍参考手册【2007年英文版】

5星(超过95%的资源)
所需积分/C币:9 2013-08-08 11:02:13 3.56MB PDF
1
收藏 收藏
举报

Ruby 袖珍参考手册【2007年英文版】
Ruby pocket Reference by Michael Fi Copyright C 2007 Michael Fitzgerald. All rights reserved Printed in Canada Pub ished by O'Reilly Media, Inc, 1005 Gravenstein Highway North o,CA9547 promotional use. Online editions are also available for most titles (safari oreilly. com). For more information, contact our corporate/ institutionalsalesdepartment(800,998-9938orcorporate(@oreilly.com Editor: Simon St Laurent Cover Designer: Karen Montgomery Production editor Interior Designer David Fu llustrators Robert ri nd Proofreader: Rachel Monaghan Indexer: Ellen Troutman Zai Printing His July 2007 First edition Nutshell Handbook, the Nutshell Handbook logo, and the O'Reilly logo are registered trademarks of o'Reilly Media, Inc. The Pocket referer designations, Ruby Pocket Reference, the image of a giraffe, and related trade cress are trademarks of O'Reilly media, Inc Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O Reilly media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps While lution has been tak the of this book. the ublisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein ISBN-10:0-596-51481-6 ISBN-13:978-0-596-51481-5 Contents Running Ruby Running the ruby Interpreter Using a Shebang Line on Unix/Linux Associating File Types on Windows Reserved words Operators Comments Numbers 11 Variables Local variables Instance variable Class variables Global variables Constants 13 Parallel assic ignment of variable Symbols 14 Predefined variables 14 Pseudovariables Global constants 18 Ranges 19 Methods 19 20 Return values 20 Method name conventions 21 Default Arguments 22 Variable arguments Aliasing method 23 Blocks 23 Procs 25 Conditional statements The if statement 27 The unless statement 29 The while statement The until statement 31 The case stat 32 The for lot The ternary operate Executing code before or after a program Classes 34 Instance variables 36 Accessors 38 Class methods 40 Singletons 40 Inheritance 42 Public, private or pr 42 Modules and mixins 44 ⅣV es Creating a New file 47 Opening an existing fil 48 ARGV and arge 48 Renaming and deleting files File Inquiries File modes and ownership The 1o class 52 54 The rescue and ensure clauses The raise method The catch and throw methods Object class Object Instance methods Kernel module String Cla Expression Substitution 73 General delimited stri 73 Here documents 73 Escape characters Character Encoding Regular Expressions String methods 81 Array Cia 94 Creating arrays Array class methods 96 Array Instance methods 96 Contents Hash class Creating Hasht 107 Hash class methods 108 Hash instance methods 108 Time Formatting Directives 113 Interactive Ruby (irb) 114 Ruby debugger 117 Ruby documentation RDoc Options 121 RubyGems 125 Rake 131 Ruby resources 133 Glossary 134 Index 151 Ruby pocket reference Ruby is an open source, object-oriented programming lan- guage created by Yukihiro "Matz"Matsumoto. First released in Japan in 1995, Ruby has gained worldwide acceptance as an easy-to-learn, powerful, anld expressive language, espe cially since the advent of Ruby on rails, a web application frameworkwritteninRuby(http://www.rubyonrails.org Ruby's core is written in the C programming language and runs on all major platforms. It is an interpreted rather than compiledlanguageFormoreintormationonRubyseehttp:// www.ruby-lang.org Conventions used in this book The following font conventions are used in this book Indicates pathnames and filenames (such as program names): Internet addresses, such as domain names and URLS; and emphasized or newly defined terms Constant width Indicates commands and options that should be typed ver batim in a file or in irb; or names and keywords in ruby programs, including method, variable, and class names Constant width italic Indicates user-supplied values Constant width bold Used to draw attention to parts of programs Comments and Questions Please address comments and questions concerning this book to the publisher O Reilly media, Inc 1005 Gravenstein Highway North Sebastopol, CA 95472 800-998-9938(in the United States or Canada) 707-829-0515 (international or local 707-8290104(Fax) There is a web page for this book, which lists errata, examples, or any additional information. You can access this page at http://www.oreilly.com/catalog/9780596514815 To comment or ask technical questions about this book send email to bookquestions(@oreilly.com For information about books. conferences. Resource Cen- ters, and the O'Reilly ne rk, see the o'reilly web site at http:// www.ore Acknowledgments This book is dedicated to John H. Atkinson, Jr(1934-2007) i want to thank Simon St Laurent, Ryan Waldron, and Rachel Monaghan for their help in creating, editing, and producing this book Running Ruby Test to see whether Ruby is running on your computer by typing the following at a shell or command prompt ruby --version 2 Ruby Pocket Reference An affirmative response will look similar to this(this exaIll ple is for version 1.8.6 running on Mac OS X) ruby 1.8.6(2007-03-13 patchlevel o)[powerpc-darwin890 You can install Ruby on any of the major platforms. For Rubyfilearchivesandinstallationinstructionsseehttp:// www.ruby-lang.org/en/downloads Running the Ruby Interpreter ruby [switches][--] [program filename] [arguments] Switches(or command-line options oloctal] Specify a record separator (\o if no argument) Autosplit mode with ( splits$into轩F) heck syntax only Directory cd to directory before executing your script or program d Set debugging flags(set predefined variable sDEBUG to true Execute one line of script. Several Omit Iprogram file split() pattern for autosplit (-a Lextension] Edit ARGv files in place(make backup if extension supplied) Directa Specify $LOAD_ PATH (predefined variable) directory; may be used more than once Running Ruby

...展开详情
试读 127P Ruby 袖珍参考手册【2007年英文版】
立即下载 身份认证VIP会员低至7折
一个资源只可评论一次,评论内容不能少于5个字
thy38 不错,就喜欢这种袖珍手册了。我也做了本《设计模式便携手册》。
2014-09-16
回复
您会向同学/朋友/同事推荐我们的CSDN下载吗?
谢谢参与!您的真实评价是我们改进的动力~
关注 私信
上传资源赚钱or赚积分
最新推荐
Ruby 袖珍参考手册【2007年英文版】 9积分/C币 立即下载
1/127
Ruby 袖珍参考手册【2007年英文版】第1页
Ruby 袖珍参考手册【2007年英文版】第2页
Ruby 袖珍参考手册【2007年英文版】第3页
Ruby 袖珍参考手册【2007年英文版】第4页
Ruby 袖珍参考手册【2007年英文版】第5页
Ruby 袖珍参考手册【2007年英文版】第6页
Ruby 袖珍参考手册【2007年英文版】第7页
Ruby 袖珍参考手册【2007年英文版】第8页
Ruby 袖珍参考手册【2007年英文版】第9页
Ruby 袖珍参考手册【2007年英文版】第10页
Ruby 袖珍参考手册【2007年英文版】第11页
Ruby 袖珍参考手册【2007年英文版】第12页
Ruby 袖珍参考手册【2007年英文版】第13页
Ruby 袖珍参考手册【2007年英文版】第14页
Ruby 袖珍参考手册【2007年英文版】第15页
Ruby 袖珍参考手册【2007年英文版】第16页
Ruby 袖珍参考手册【2007年英文版】第17页
Ruby 袖珍参考手册【2007年英文版】第18页
Ruby 袖珍参考手册【2007年英文版】第19页
Ruby 袖珍参考手册【2007年英文版】第20页

试读结束, 可继续阅读

9积分/C币 立即下载