Huw CollingbourneDownload source code from:http://www.sapphiresteel.comYou may freely copy and distribute this eBook as long as you do not modifythe text or remove this copyright notice. You must not make any charge forthis eBook.The Little Book of Ruby is produced in association with Rosedown Mill Ltd.,makers of the Steel IDE for Visual Studio (www.sapphiresteel.com) andBitwise Magazine – the online magazine for developers(www.bitwisemag.com
Welcome To The Little Book Of Ruby...........................................................................5Learn Ruby In Ten Chapters…..............................................................................5What Is Ruby?.......................................................................................................5What Is Rails?........................................................................................................5Download Ruby plus an Editor ..............................................................................6Get The Source Code Of The Sample Programs...................................................6Running Ruby Programs........................................................................................6How To Use This Book ..........................................................................................7Making Sense Of The Text....................................................................................7Chapter One.....................................................................................................................8Strings and Embedded Evaluation.......................................................................11Methods...............................................................................................................12 Numbers...............................................................................................................14Testing a Condition: if … then.............................................................................15Chapter Two..................................................................................................................17Instances and Instance Variables..........................................................................18Constructors – new and initialize.........................................................................21Inspecting Objects................................................................................................22Chapter Three................................................................................................................25Superclasses and Subclasses................................................................................28Chapter Four .................................................................................................................30Accessor Methods................................................................................................30Attribute Readers and Writers..............................................................................32Attributes Create Variables..................................................................................34Calling Methods of a Superclass.........................................................................37Class Variables.....................................................................................................38Chapter Five..................................................................................................................40Using Arrays........................................................................................................40Creating Arrays....................................................................................................41Multi-Dimensional Arrays...................................................................................43Iterating Over Arrays...........................................................................................45Indexing Into Arrays............................................................................................46Chapter Six....................................................................................................................48Creating Hashes...................................................................................................48Indexing Into A Hash...........................................................................................50