Ruby In A Nutshell
Yukihiro Matsumoto
Language: English
Pages: 230
ISBN: 0596002149
Format: PDF / Kindle (mobi) / ePub
With Ruby in a Nutshell, Matsumoto offers a practical reference to the features of this new language including the command-line options, syntax, built-in variables, functions, and many commonly used classes and modules. This guide covers the current stable version of Ruby (1.6), yet is applicable to the development version 1.7 and the next planned stable version 1.8. You will find a thorough description of Ruby's language syntax, and a description of the core functionality built into the standard Ruby interpreter, which has more than 800 built-in methods in 42 classes and modules.
Ruby finds its power through its built-in libraries, and this handy volume take you through the many useful libraries that come with the standard Ruby distribution--from network access via Http and Cgi programming, to data persistence using the Dbm library. This book concludes with coverage of the unique tools that come with Ruby, including the debugger, profiler, and irb (or interactive ruby.)
Find out how Ruby combines the strengths of other languages, and why it has captured the interest of so many open source programmers. As part of the successful "in a nutshell" s
x) {...} Replaces the first string matching x in $_ with y. If a block is specified, matched strings are replaced with the result of the block. The modified result is assigned to $_. See String#sub in Section 3.4. sub!( x, y) sub!( x) {...} Performs the same replacement as sub, except the string is changed in place. test( test, f1[, f2]) Performs one of the following file tests specified by the character test. In order to improve readability, you should use File class methods (for example
will its Standard Library, to everyone's benefit. Although not every library section will contain all these entries, the basic format for each section is as follows: ● Required library ● Example ● Inherited class ● Class methods ● Instance methods 4.1.1 Network Use Ruby's network classes to let your scripts speak basic protocols such as TCP and UDP as a client, a server, or both. These libraries provide socket access to a variety of Internet protocols and classes that make access to
968263756 Searches the mailbox for messages that match the given searching criteria, and returns an array of message sequence numbers. imap.search(["SUBJECT", "hello"]) #=> [1, 6, 7, 8] imap.search('SUBJECT "hello"') #=> [1, 6, 7, 8] imap.select( mailbox) Selects a mailbox as a current mailbox so that messages in the mailbox can be accessed. imap.sort( sort_keys, search_keys, charset) Returns an array of message sequence numbers that matches search_keys_sorted according to the sort_keys.
Backslash notations Sequence \n \r \f \b \a \e \s \nnn \xnn \cx, \C-x \M-x \M-\C-x \x Character represented Newline (0x0a) Carriage return (0x0d) Formfeed (0x0c) Backspace (0x08) Bell (0x07) Escape (0x1b) Space (0x20) Octal notation (n being 0-7) Hexadecimal notation (n being 0-9, a-f, or A-F) Control-x Meta-x (c | 0x80) Meta-Control-x Character x `command` Converts command output to a string. Allows substitution and backslash notation 2.4.2.4 General delimited strings The delimiter ! in
occurrences of preceding expression. re{ n, m} Matches at least n and at most m occurrences of preceding expression. a| b Matches either a or b. ( re) Groups regular expressions and remembers matched text. (?imx) Temporarily toggles on i, m, or x options within a regular expression. If in parentheses, only that area is affected. (?-imx) Temporarily toggles off i, m, or x options within a regular expression. If in parentheses, only that area is affected. (?: re) Groups regular expressions