SlideShare una empresa de Scribd logo
1 de 2
Descargar para leer sin conexión
def    <=>(rhs)
                                                                                                                                                                                                                        Mode Strings
                          Ruby Language QuickRef                                                                                 #    ...
                                                                                                                                                                                                                         r          Read-only, starts at beginning of file (default mode).
                                                                                                                               end
                                                                                                                               def    succ
                                                                                                                                                                                                                         r+         Read-write, starts at beginning of file.
                                                                                                                                 #    ...
General Syntax Rules                                                                                                           end
                                                                                                                             end                                                                                         w          Write-only, truncates existing file to zero length or creates a new file for writing.
  Comments start with a pound/sharp (#) character and go to EOL.                                                             range    = RangeThingy.new(lower_bound) .. RangeThingy.new(upper_bound)
                                                                                                                                                                                                                         w+         Read-write, truncates existing file to zero length or creates a new file for reading
  Lines between ‘=begin’ and ‘=end’ are skipped by the interpreter.
                                                                                                                           Regexen                                                                                                  and writing.
  Ruby programs are sequence of expressions.                                                                                    /normal regex/[xim]
                                                                                                                                                                                                                         a          Write-only, starts at end of file if file exists, otherwise creates a new file for
                                                                                                                                %r|alternate form|[xim]
  Each expression is delimited by semicolons (;) or newlines unless obviously incomplete (e.g.                                                                                                                                      writing.
                                                                                                                                Regex.new(pattern, options)
  trailing ‘+’).
                                                                                                                                                                                                                         a+         Read-write, starts at end of file if file exists, otherwise creates a new file for
                                                                                                                                        .              any character except newline
  Backslashes at the end of line does not terminate expression.                                                                                                                                                                     reading and writing.
                                                                                                                                        [set]          any single character of set
                                                                                                                                                                                                                         b          Binary file mode (may appear with any of the key letters listed above). Only
Reserved Words                                                                                                                                                                                                                      necessary for DOS/Windows.
                                                                                                                                        [^set]         any single character NOT of set
  alias         and           BEGIN          begin         break         case                                                           *              0 or more previous regular expression
                                                                                                                                                                                                                        Variables and Constants
  class         def           defined do                   else          elsif                                                          *?             0 or more previous regular expression (non greedy)                $global_variable
  END           end           ensure         false         for           if                                                                                                                                              @instance_variable
                                                                                                                                        +              1 or more previous regular expression                             [OtherClass::]CONSTANT
  in            module        next           nil           not           or                                                                                                                                              local_variable
                                                                                                                                        +?             1 or more previous regular expression (non greedy)
  redo          rescue        retry          return        self          super
                                                                                                                                                                                                                        Pseudo-variables
                                                                                                                                        ?              0 or 1 previous regular expression
  then          true          undef          unless        until         when
                                                                                                                                        |              alternation                                                       self                          the receiver of the current method
  while         yield
                                                                                                                                        ()             grouping regular expressions                                      nil                           the sole instance of NilClass (represents false)
                                                                                                                                        ^              beginning of a line or string                                     true                          the sole instance of TrueClass (typical true value)
Types
Basic types are numbers, strings, ranges, regexen, symbols, arrays, and hashes. Also included are files because they are                $              end of a line or string                                           false                         the sole instance of FalseClass (represents false)
used so often.
                                                                                                                                        #{m,n}         at least m but most n previous regular expression                 __FILE__                      the current source file name.
Numbers
                                                                                                                                        #{m,n}?        at least m but most n previous regular expression (non greedy)
  123 1_234 123.45 1.2e-3                                                                                                                                                                                                __LINE__                      the current line number in the source file.
                                                                                                                                        A             beginning of a string
  0xffff (hex) 0b01011 (binary) 0377 (octal)
                                                                                                                                                                                                                        Pre-defined Variables
                                                                                                                                        b             backspace (0x08, inside [] only)
  ?a      ASCII character
                                                                                                                                                                                                                         $!                    The exception information message set by ‘raise’.
                                                                                                                                        B             non-word boundary
  ?C-a    Control-a
                                                                                                                                                                                                                         $@                    Array of backtrace of the last exception thrown.
                                                                                                                                        b             word boundary (outside [] only)
  ?M-a     Meta-a
                                                                                                                                                                                                                         $&                    The string matched by the last successful pattern match in this scope.
                                                                                                                                        d             digit, same as[0-9]
  ?M-C-a Meta-Control-a
                                                                                                                                                                                                                         $`                    The string to the left of the last successful match.
                                                                                                                                        D             non-digit
Strings                                                                                                                                                                                                                  $'                    The string to the right of the last successful match.
                                                                                                                                        S             non-whitespace character
In all of the %() cases below, you may use any matching characters or any single character for delimiters. %[], %!!,
                                                                                                                                                                                                                         $+                    The last bracket matched by the last successful match.
%@@, etc.
                                                                                                                                        s             whitespace character[ tnrf]
  'no interpolation'                                                                                                                                                                                                     $1                    The Nth group of the last successful match. May be > 1.
                                                                                                                                        W             non-word character
  quot;#{interpolation} and backslashesnquot;
                                                                                                                                                                                                                         $~                    The information about the last match in the current scope.
                                                                                                                                        w             word character[0-9A-Za-z_]
  %q(no interpolation)
                                                                                                                                                                                                                         $=                    The flag for case insensitive, nil by default.
                                                                                                                                        z             end of a string
  %Q(interpolation and backslashes)
                                                                                                                                                                                                                         $/                    The input record separator, newline by default.
                                                                                                                                        Z             end of a string, or before newline at the end
  %(interpolation and backslashes)
                                                                                                                                                                                                                         $                    The output record separator for the print and IO#write. Default is nil.
                                                                                                                                        (?# )          comment
  `echo command interpretation with interpolation and
                                                                                                                                                                                                                         $,                    The output field separator for the print and Array#join.
  backslashes`                                                                                                                          (?: )          grouping without backreferences
                                                                                                                                                                                                                         $;                    The default separator for String#split.
  %x(echo command interpretation with interpolation and                                                                                 (?= )          zero-width positive look-ahead assertion (?! )
  backslashes)                                                                                                                                                                                                           $.                    The current input line number of the last file that was read.
                                                                                                                                        (?ix-ix)       turns on/off i/x options, localized in group if any.
                                                                                                                                                                                                                         $<                    The virtual concatenation file of the files given on command line.
Backslashes                                                                                                                             (?ix-ix: )     turns on/off i/x options, localized in non-capturing group.
       t (tab), n (newline), r (carriage return),
                                                                                                                                                                                                                         $>                    The default output for print, printf. $stdout by default.
       f (form feed), b (backspace), a (bell),
       e (escape), s (whitespace), nnn (octal),
                                                                                                                           Arrays                                                                                        $_                    The last input line of string by gets or readline.
       xnn (hexadecimal), cx (control x),
                                                                                                                             [1, 2, 3]
       C-x (control x), M-x (meta x),
                                                                                                                             %w(foo bar baz)               # no interpolation                                            $0                    Contains the name of the script being executed. May be assignable.
       M-C-x (meta control x)
                                                                                                                             %W(foo #{bar} baz)            # interpolation
                                                                                                                                                                                                                         $*                    Command line arguments given for the script sans args.
Here Docs                                                                                                                  Indexes may be negative, and they index backwards (-1 is the last element).
       <<identifier          #   interpolation                                                                                                                                                                           $$                    The process number of the Ruby running this script.
                                                                                                                           Hashes
       <<quot;identifierquot;        #   interpolation
                                                                                                                             { 1 => 2, 2 => 4, 3 => 6 }
       <<'identifier'        #   no interpolation                                                                                                                                                                        $?                    The status of the last executed child process.
                                                                                                                             { expr => expr, ... }
       <<-identifier         #   interpolation, indented end
       <<-quot;identifierquot;       #   interpolation, indented end                                                                                                                                                             $:                    Load path for scripts and binary modules by load or require.
       <<-'identifier'       #   no interpolation, indented end
                                                                                                                           Files
                                                                                                                                                                                                                         $quot;                    The array contains the module names loaded by require.
                                                                                                                           Common methods include:
Symbols                                                                                                                      File.join(p1, p2, ... pN) => “p1/p2/.../pN© platform independent paths                      $DEBUG                The status of the -d switch.
A symbol (:symbol) is an immutable name used for identifiers, variables, and operators.
Ranges                                                                                                                       File.new(path, mode_string=quot;rquot;) => file                                                     $FILENAME             Current input file from $<. Same as $<.filename.
       1..10
                                                                                                                             File.new(path, mode_num [, perm_num]) => file                                               $LOAD_PATH            The alias to the $:.
       'a'..'z'
       (1..10) === 5         -> true
                                                                                                                             File.open(filename, mode_string=quot;rquot;) {|file| block} -> nil                                  $stderr               The current standard error output.
       (1..10) === 15        -> false
                                                                                                                             File.open(filename [, mode_num [, perm_num ]]) {|file| block} -> nil                        $stdin                The current standard input.
    # prints lines starting at 'start' and
    # ending at 'end'
                                                                                                                             IO.foreach(path, sepstring=$/) {|line| block}                                               $stdout               The current standard output.
  while gets
    print if /start/../end/
                                                                                                                             IO.readlines(path) => array                                                                 $VERBOSE              The verbose flag, which is set by the -v switch.
  end

                                                                                                                                                                                                                         $-0                   The alias to $/.
  class RangeThingy
# (comparisons may be regexen)                                                                                          methods and constants.
  $-a                       True if option -a is set. Read-only variable.                                                      when comparison [, comparison]... [then]                                                                                  class A
                                                                                                                                 body                                                                                                                      protected
  $-d                       The alias to $DEBUG.                                                                               when comparison [, comparison]... [then]                                                                                    def protected_method; ...; end
                                                                                                                                 body                                                                                                                    end
  $-F                       The alias to $;.                                                                                   ...                                                                                                                       class B < A
                                                                                                                             [else                                                                                                                         public
  $-i                       In in-place-edit mode, this variable holds the extention, otherwise nil.                           body]                                                                                                                       def test_protected
                                                                                                                             end                                                                                                                              myA = A.new
  $-I                       The alias to $:.                                                                                                                                                                                                                  myA.protected_method
                                                                                                                             while bool-expr [do]                                                                                                          end
  $-l                       True if option -l is set. Read-only variable.                                                     body                                                                                                                       end
                                                                                                                             end                                                                                                                         b = B.new.test_protected
  $-p                       True if option -p is set. Read-only variable.
                                                                                                                             until bool-expr [do]
                                                                                                                                                                                                                                                         Accessors
  $-v                       The alias to $VERBOSE.                                                                            body
                                                                                                                                                                                                                                                         Module provides the following utility methods:
                                                                                                                             end
                                                                                                                                                                                                                                                           attr_reader <attribute>[,                            Creates a read-only accessor for each
Pre-defined Global Constants                                                                                                 begin
                                                                                                                                                                                                                                                           <attribute>]...                                      <attribute>.
                                                                                                                              body
  TRUE                                    The typical true value.                                                            end while bool-expr
                                                                                                                                                                                                                                                           attr_writer <attribute>[,                            Creates a write-only accessor for each
                                                                                                                                                                                                                                                           <attribute>]...                                      <attribute>.
  FALSE                                   The false itself.                                                                  begin
                                                                                                                              body
                                                                                                                                                                                                                                                           attr <attribute> [,                                  Equivalent to quot;attr_reader <attribute>;
  NIL                                     The nil itself.                                                                    end until bool-expr
                                                                                                                                                                                                                                                           <writable>]                                          attr_writer <attribute> if
  STDIN                                   The standard input. The default value for $stdin.                                  for name[, name]... in expr [do]                                                                                                                                                   <writable>quot;
                                                                                                                               body
  STDOUT                                  The standard output. The default value for $stdout.                                end                                                                                                                           attr_accessor <attribute>[,                          Equivalent to quot;attr <attribute>, truequot; for
                                                                                                                                                                                                                                                           <attribute>]...                                      each argument.
  STDERR                                  The standard error output. The default value for $stderr.                          expr.each do | name[, name]... |
                                                                                                                               body
                                                                                                                             end
  ENV                                     The hash contains current environment variables.
                                                                                                                                                                                                                                                         Aliasing
                                                                                                                                                                                                                                                         alias <old> <new>
                                                                                                                             expr while bool-expr
  ARGF                                    The alias to the $<.
                                                                                                                                                                                                                                                         Creates a new reference to whatever old referred to. old can be any existing method, operator, global. It may not be a
                                                                                                                             expr until bool-expr
                                                                                                                                                                                                                                                         local, instance, constant, or class variable.
  ARGV                                    The alias to the $*.
                                                                                                                                                                                                                                                         Blocks, Closures, and Procs
                                                                                                                               break                            terminates loop immediately.
  DATA                                    The file object of the script, pointing just after __END__.
                                                                                                                                                                                                                                                         Blocks/Closures
                                                                                                                               redo                             immediately repeats w/o rerunning the condition.
  RUBY_VERSION                            The ruby version string (VERSION was depricated).                                                                                                                                                              Blocks must follow a method invocation:
                                                                                                                               next                             starts the next iteration through the loop.                                              invocation do ... end
  RUBY_RELEASE_DATE                       The relase date string.                                                                                                                                                                                        invocation do || ... end
                                                                                                                               retry                            restarts the loop, rerunning the condition.                                              invocation do |arg_list| ... end
  RUBY_PLATFORM                           The platform identifier.                                                                                                                                                                                       invocation { ... }
                                                                                                                                                                                                                                                         invocation { || ... }
                                                                                                                             Invoking a Method                                                                                                           invocation { |arg_list| ... }
Expressions                                                                                                                  Nearly everything available in a method invocation is optional, consequently the syntax is very difficult to follow. Here
Terms                                                                                                                                                                                                                                                      Blocks are full closures, remembering their variable context.
                                                                                                                             are some examples:
Terms are expressions that may be a basic type (listed above), a shell command, variable reference, constant reference, or     method                                                                                                                      Blocks are invoked via yield and may be passed arguments.
method invocation.
                                                                                                                               obj.method
Operators and Precedence                                                                                                                                                                                                                                   Block arguments may not have default parameters.
  ::                                                                                                                           Class::method                                                                                                               Brace form ({/}) has higher precedence and will bind to the last parameter if the invocation
                                                                                                                                                                                                                                                           is made without parentheses.
  []                                                                                                                           method(arg1, arg2)
                                                                                                                                                                                                                                                           do/end form has lower precedence and will bind to the invocation even without parentheses.
  **                                                                                                                           method(arg1, key1 => val1, key2 => val2, aval1, aval2) { block }
  - (unary) + (unary) ! ~                                                                                                      method(arg1, *[arg2, arg3]) becomes: method(arg1, arg2, arg3)
                                                                                                                                                                                                                                                         Proc Objects
  *     /    %                                                                                                                                                                                                                                           See class Proc for more information. Created via:
                                                                                                                             call   := [receiver ('::' | '.')] name [params] [block]                                                                     Kernel#proc (or Kernel#lambda)
                                                                                                                             params := ( [param]* [, hash] [*arr] [&proc] )
  +     -                                                                                                                                                                                                                                                Proc#new
                                                                                                                             block := { body } | do body end                                                                                             &block argument on a method
  <<     >>
                                                                                                                             Defining a Class                                                                                                            Exceptions
  &




                                                                                                                                                                                                                                                                                                                                                                                  Copyright © 2005 Ryan Davis with Austin Ziegler. PDF version by Austin Ziegler. Licensed under the
                                                                                                                                                                                                                                                         begin
                                                                                                                             Class names begin with capital characters.
  |     ^                                                                                                                                                                                                                                                  expr
                                                                                                                             class Identifier [ < Superclass ]; ... ; end
                                                                                                                                                                                                                                                         [ rescue [ exception_class [ => var ], ... ]
  >     >=     <    <=                                                                                                                                                                                                                                     expr ]
                                                                                                                                 #     Singleton classes, or idioclasses;
                                                                                                                                                                                                                                                         [ else
                                                                                                                                 #     add methods to a single instance
  <=> == === != =~ !~                                                                                                                                                                                                                                      expr ]
                                                                                                                                 #     obj can be self
                                                                                                                                                                                                                                                         [ ensure
                                                                                                                             class     << obj; ...; end
  &&                                                                                                                                                                                                                                                       expr ]
                                                                                                                                                                                                                                                         end
                                                                                                                             Defining a Module
  ||
                                                                                                                                                                                                                                                         raise [ exception_class, ] [ message ]
                                                                                                                             Module names begin with capital characters.
  .. ...                                                                                                                     module Identifier; ...; end
                                                                                                                                                                                                                                                         The default exception_class for rescue is StandardError, not Exception. Raise without an exception_class raises a
  = (+=, -=, ...)
                                                                                                                             Defining a Method                                                                                                           RuntimeError. All exception classes must inherit from Exception or one of its children (listed below).
                                                                                                                             def method_name(arg_list); ...; end
  not                                                                                                                                                                                                                                                      StandardError            LocalJumpError, SystemStackError, ZeroDivisionError, RangeError
                                                                                                                             def expr.method_name(arg_list); ...; end
                                                                                                                                                                                                                                                                                    (FloatDomainError), SecurityError, ThreadError, IOError (EOFError),
  and or
                                                                                                                                                                                                                                                                                    ArgumentError, IndexError, RuntimeError, TypeError,
                                                                                                                               arg_list := ['('] [varname*] ['*' listname] ['&' blockname] [')']                                                                                    SystemCallError (Errno::*), RegexpError
Control Expressions                                                                                                            Arguments may have default values (varname = expr).                                                                         SignalException
if bool-expr [then]
  body                                                                                                                         Method definitions may not be nested.                                                                                       Interrupt
elsif bool-expr [then]
  body                                                                                                                         method_name may be an operator: <=>, ==, ===, =~, <, <=, > >=, +, -, *, /,                                                  NoMemoryError
else
                                                                                                                               %, **, <<, >>, ~, +@, -@, [], []= (the last takes two arguments)
  body
                                                                                                                                                                                                                                                           ScriptError              LoadError, NameError, SyntaxError, NotImplementedError
end
                                                                                                                             Access Restriction                                                                                                            SystemExit
unless bool-expr [then]
  body                                                                                                                         public          totally accessable.
else
                                                                                                                                                                                                                                                         Catch and Throw
  body                                                                                                                         protected       accessable only by instances of class and direct descendants. Even through
end                                                                                                                                                                                                                                                      catch :label do
                                                                                                                                               hasA relationships. (see below)                                                                             expr
expr if     bool-expr                                                                                                                                                                                                                                      throw :label
                                                                                                                               private         accessable only by instances of class.
expr unless bool-expr                                                                                                                                                                                                                                    end

case target-expr                                                                                                             Restriction used without arguments set the default access control. Used with arguments, sets the access of the named

Más contenido relacionado

Más de 51 lecture

1244600439API2 upload
1244600439API2 upload1244600439API2 upload
1244600439API2 upload51 lecture
 
1242982622API2 upload
1242982622API2 upload1242982622API2 upload
1242982622API2 upload51 lecture
 
1242982374API2 upload
1242982374API2 upload1242982374API2 upload
1242982374API2 upload51 lecture
 
1242626441API2 upload
1242626441API2 upload1242626441API2 upload
1242626441API2 upload51 lecture
 
1242625986my upload
1242625986my upload1242625986my upload
1242625986my upload51 lecture
 
1242361147my upload ${file.name}
1242361147my upload ${file.name}1242361147my upload ${file.name}
1242361147my upload ${file.name}51 lecture
 
this is ruby test
this is ruby testthis is ruby test
this is ruby test51 lecture
 
this is ruby test
this is ruby testthis is ruby test
this is ruby test51 lecture
 
this is ruby test
this is ruby testthis is ruby test
this is ruby test51 lecture
 
this is ruby test
this is ruby testthis is ruby test
this is ruby test51 lecture
 
this is test api2
this is test api2this is test api2
this is test api251 lecture
 
My cool new Slideshow!
My cool new Slideshow!My cool new Slideshow!
My cool new Slideshow!51 lecture
 
Stress Management
Stress Management Stress Management
Stress Management 51 lecture
 
Iim A Managment
Iim A ManagmentIim A Managment
Iim A Managment51 lecture
 
Time Management
Time ManagementTime Management
Time Management51 lecture
 
Conversation By Design
Conversation By DesignConversation By Design
Conversation By Design51 lecture
 
dynamics-of-wikipedia-1196670708664566-3
dynamics-of-wikipedia-1196670708664566-3dynamics-of-wikipedia-1196670708664566-3
dynamics-of-wikipedia-1196670708664566-351 lecture
 
Tech_Implementation of Complex ITIM Workflows
Tech_Implementation of Complex ITIM WorkflowsTech_Implementation of Complex ITIM Workflows
Tech_Implementation of Complex ITIM Workflows51 lecture
 
javascript reference
javascript referencejavascript reference
javascript reference51 lecture
 

Más de 51 lecture (20)

1244600439API2 upload
1244600439API2 upload1244600439API2 upload
1244600439API2 upload
 
1242982622API2 upload
1242982622API2 upload1242982622API2 upload
1242982622API2 upload
 
1242982374API2 upload
1242982374API2 upload1242982374API2 upload
1242982374API2 upload
 
1242626441API2 upload
1242626441API2 upload1242626441API2 upload
1242626441API2 upload
 
1242625986my upload
1242625986my upload1242625986my upload
1242625986my upload
 
1242361147my upload ${file.name}
1242361147my upload ${file.name}1242361147my upload ${file.name}
1242361147my upload ${file.name}
 
this is ruby test
this is ruby testthis is ruby test
this is ruby test
 
this is ruby test
this is ruby testthis is ruby test
this is ruby test
 
this is ruby test
this is ruby testthis is ruby test
this is ruby test
 
this is ruby test
this is ruby testthis is ruby test
this is ruby test
 
this is test api2
this is test api2this is test api2
this is test api2
 
My cool new Slideshow!
My cool new Slideshow!My cool new Slideshow!
My cool new Slideshow!
 
Stress Management
Stress Management Stress Management
Stress Management
 
Iim A Managment
Iim A ManagmentIim A Managment
Iim A Managment
 
Time Management
Time ManagementTime Management
Time Management
 
Conversation By Design
Conversation By DesignConversation By Design
Conversation By Design
 
Web 2.0
Web 2.0Web 2.0
Web 2.0
 
dynamics-of-wikipedia-1196670708664566-3
dynamics-of-wikipedia-1196670708664566-3dynamics-of-wikipedia-1196670708664566-3
dynamics-of-wikipedia-1196670708664566-3
 
Tech_Implementation of Complex ITIM Workflows
Tech_Implementation of Complex ITIM WorkflowsTech_Implementation of Complex ITIM Workflows
Tech_Implementation of Complex ITIM Workflows
 
javascript reference
javascript referencejavascript reference
javascript reference
 

Último

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 

Último (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

this is ruby test

  • 1. def <=>(rhs) Mode Strings Ruby Language QuickRef # ... r Read-only, starts at beginning of file (default mode). end def succ r+ Read-write, starts at beginning of file. # ... General Syntax Rules end end w Write-only, truncates existing file to zero length or creates a new file for writing. Comments start with a pound/sharp (#) character and go to EOL. range = RangeThingy.new(lower_bound) .. RangeThingy.new(upper_bound) w+ Read-write, truncates existing file to zero length or creates a new file for reading Lines between ‘=begin’ and ‘=end’ are skipped by the interpreter. Regexen and writing. Ruby programs are sequence of expressions. /normal regex/[xim] a Write-only, starts at end of file if file exists, otherwise creates a new file for %r|alternate form|[xim] Each expression is delimited by semicolons (;) or newlines unless obviously incomplete (e.g. writing. Regex.new(pattern, options) trailing ‘+’). a+ Read-write, starts at end of file if file exists, otherwise creates a new file for . any character except newline Backslashes at the end of line does not terminate expression. reading and writing. [set] any single character of set b Binary file mode (may appear with any of the key letters listed above). Only Reserved Words necessary for DOS/Windows. [^set] any single character NOT of set alias and BEGIN begin break case * 0 or more previous regular expression Variables and Constants class def defined do else elsif *? 0 or more previous regular expression (non greedy) $global_variable END end ensure false for if @instance_variable + 1 or more previous regular expression [OtherClass::]CONSTANT in module next nil not or local_variable +? 1 or more previous regular expression (non greedy) redo rescue retry return self super Pseudo-variables ? 0 or 1 previous regular expression then true undef unless until when | alternation self the receiver of the current method while yield () grouping regular expressions nil the sole instance of NilClass (represents false) ^ beginning of a line or string true the sole instance of TrueClass (typical true value) Types Basic types are numbers, strings, ranges, regexen, symbols, arrays, and hashes. Also included are files because they are $ end of a line or string false the sole instance of FalseClass (represents false) used so often. #{m,n} at least m but most n previous regular expression __FILE__ the current source file name. Numbers #{m,n}? at least m but most n previous regular expression (non greedy) 123 1_234 123.45 1.2e-3 __LINE__ the current line number in the source file. A beginning of a string 0xffff (hex) 0b01011 (binary) 0377 (octal) Pre-defined Variables b backspace (0x08, inside [] only) ?a ASCII character $! The exception information message set by ‘raise’. B non-word boundary ?C-a Control-a $@ Array of backtrace of the last exception thrown. b word boundary (outside [] only) ?M-a Meta-a $& The string matched by the last successful pattern match in this scope. d digit, same as[0-9] ?M-C-a Meta-Control-a $` The string to the left of the last successful match. D non-digit Strings $' The string to the right of the last successful match. S non-whitespace character In all of the %() cases below, you may use any matching characters or any single character for delimiters. %[], %!!, $+ The last bracket matched by the last successful match. %@@, etc. s whitespace character[ tnrf] 'no interpolation' $1 The Nth group of the last successful match. May be > 1. W non-word character quot;#{interpolation} and backslashesnquot; $~ The information about the last match in the current scope. w word character[0-9A-Za-z_] %q(no interpolation) $= The flag for case insensitive, nil by default. z end of a string %Q(interpolation and backslashes) $/ The input record separator, newline by default. Z end of a string, or before newline at the end %(interpolation and backslashes) $ The output record separator for the print and IO#write. Default is nil. (?# ) comment `echo command interpretation with interpolation and $, The output field separator for the print and Array#join. backslashes` (?: ) grouping without backreferences $; The default separator for String#split. %x(echo command interpretation with interpolation and (?= ) zero-width positive look-ahead assertion (?! ) backslashes) $. The current input line number of the last file that was read. (?ix-ix) turns on/off i/x options, localized in group if any. $< The virtual concatenation file of the files given on command line. Backslashes (?ix-ix: ) turns on/off i/x options, localized in non-capturing group. t (tab), n (newline), r (carriage return), $> The default output for print, printf. $stdout by default. f (form feed), b (backspace), a (bell), e (escape), s (whitespace), nnn (octal), Arrays $_ The last input line of string by gets or readline. xnn (hexadecimal), cx (control x), [1, 2, 3] C-x (control x), M-x (meta x), %w(foo bar baz) # no interpolation $0 Contains the name of the script being executed. May be assignable. M-C-x (meta control x) %W(foo #{bar} baz) # interpolation $* Command line arguments given for the script sans args. Here Docs Indexes may be negative, and they index backwards (-1 is the last element). <<identifier # interpolation $$ The process number of the Ruby running this script. Hashes <<quot;identifierquot; # interpolation { 1 => 2, 2 => 4, 3 => 6 } <<'identifier' # no interpolation $? The status of the last executed child process. { expr => expr, ... } <<-identifier # interpolation, indented end <<-quot;identifierquot; # interpolation, indented end $: Load path for scripts and binary modules by load or require. <<-'identifier' # no interpolation, indented end Files $quot; The array contains the module names loaded by require. Common methods include: Symbols File.join(p1, p2, ... pN) => “p1/p2/.../pN© platform independent paths $DEBUG The status of the -d switch. A symbol (:symbol) is an immutable name used for identifiers, variables, and operators. Ranges File.new(path, mode_string=quot;rquot;) => file $FILENAME Current input file from $<. Same as $<.filename. 1..10 File.new(path, mode_num [, perm_num]) => file $LOAD_PATH The alias to the $:. 'a'..'z' (1..10) === 5 -> true File.open(filename, mode_string=quot;rquot;) {|file| block} -> nil $stderr The current standard error output. (1..10) === 15 -> false File.open(filename [, mode_num [, perm_num ]]) {|file| block} -> nil $stdin The current standard input. # prints lines starting at 'start' and # ending at 'end' IO.foreach(path, sepstring=$/) {|line| block} $stdout The current standard output. while gets print if /start/../end/ IO.readlines(path) => array $VERBOSE The verbose flag, which is set by the -v switch. end $-0 The alias to $/. class RangeThingy
  • 2. # (comparisons may be regexen) methods and constants. $-a True if option -a is set. Read-only variable. when comparison [, comparison]... [then] class A body protected $-d The alias to $DEBUG. when comparison [, comparison]... [then] def protected_method; ...; end body end $-F The alias to $;. ... class B < A [else public $-i In in-place-edit mode, this variable holds the extention, otherwise nil. body] def test_protected end myA = A.new $-I The alias to $:. myA.protected_method while bool-expr [do] end $-l True if option -l is set. Read-only variable. body end end b = B.new.test_protected $-p True if option -p is set. Read-only variable. until bool-expr [do] Accessors $-v The alias to $VERBOSE. body Module provides the following utility methods: end attr_reader <attribute>[, Creates a read-only accessor for each Pre-defined Global Constants begin <attribute>]... <attribute>. body TRUE The typical true value. end while bool-expr attr_writer <attribute>[, Creates a write-only accessor for each <attribute>]... <attribute>. FALSE The false itself. begin body attr <attribute> [, Equivalent to quot;attr_reader <attribute>; NIL The nil itself. end until bool-expr <writable>] attr_writer <attribute> if STDIN The standard input. The default value for $stdin. for name[, name]... in expr [do] <writable>quot; body STDOUT The standard output. The default value for $stdout. end attr_accessor <attribute>[, Equivalent to quot;attr <attribute>, truequot; for <attribute>]... each argument. STDERR The standard error output. The default value for $stderr. expr.each do | name[, name]... | body end ENV The hash contains current environment variables. Aliasing alias <old> <new> expr while bool-expr ARGF The alias to the $<. Creates a new reference to whatever old referred to. old can be any existing method, operator, global. It may not be a expr until bool-expr local, instance, constant, or class variable. ARGV The alias to the $*. Blocks, Closures, and Procs break terminates loop immediately. DATA The file object of the script, pointing just after __END__. Blocks/Closures redo immediately repeats w/o rerunning the condition. RUBY_VERSION The ruby version string (VERSION was depricated). Blocks must follow a method invocation: next starts the next iteration through the loop. invocation do ... end RUBY_RELEASE_DATE The relase date string. invocation do || ... end retry restarts the loop, rerunning the condition. invocation do |arg_list| ... end RUBY_PLATFORM The platform identifier. invocation { ... } invocation { || ... } Invoking a Method invocation { |arg_list| ... } Expressions Nearly everything available in a method invocation is optional, consequently the syntax is very difficult to follow. Here Terms Blocks are full closures, remembering their variable context. are some examples: Terms are expressions that may be a basic type (listed above), a shell command, variable reference, constant reference, or method Blocks are invoked via yield and may be passed arguments. method invocation. obj.method Operators and Precedence Block arguments may not have default parameters. :: Class::method Brace form ({/}) has higher precedence and will bind to the last parameter if the invocation is made without parentheses. [] method(arg1, arg2) do/end form has lower precedence and will bind to the invocation even without parentheses. ** method(arg1, key1 => val1, key2 => val2, aval1, aval2) { block } - (unary) + (unary) ! ~ method(arg1, *[arg2, arg3]) becomes: method(arg1, arg2, arg3) Proc Objects * / % See class Proc for more information. Created via: call := [receiver ('::' | '.')] name [params] [block] Kernel#proc (or Kernel#lambda) params := ( [param]* [, hash] [*arr] [&proc] ) + - Proc#new block := { body } | do body end &block argument on a method << >> Defining a Class Exceptions & Copyright © 2005 Ryan Davis with Austin Ziegler. PDF version by Austin Ziegler. Licensed under the begin Class names begin with capital characters. | ^ expr class Identifier [ < Superclass ]; ... ; end [ rescue [ exception_class [ => var ], ... ] > >= < <= expr ] # Singleton classes, or idioclasses; [ else # add methods to a single instance <=> == === != =~ !~ expr ] # obj can be self [ ensure class << obj; ...; end && expr ] end Defining a Module || raise [ exception_class, ] [ message ] Module names begin with capital characters. .. ... module Identifier; ...; end The default exception_class for rescue is StandardError, not Exception. Raise without an exception_class raises a = (+=, -=, ...) Defining a Method RuntimeError. All exception classes must inherit from Exception or one of its children (listed below). def method_name(arg_list); ...; end not StandardError LocalJumpError, SystemStackError, ZeroDivisionError, RangeError def expr.method_name(arg_list); ...; end (FloatDomainError), SecurityError, ThreadError, IOError (EOFError), and or ArgumentError, IndexError, RuntimeError, TypeError, arg_list := ['('] [varname*] ['*' listname] ['&' blockname] [')'] SystemCallError (Errno::*), RegexpError Control Expressions Arguments may have default values (varname = expr). SignalException if bool-expr [then] body Method definitions may not be nested. Interrupt elsif bool-expr [then] body method_name may be an operator: <=>, ==, ===, =~, <, <=, > >=, +, -, *, /, NoMemoryError else %, **, <<, >>, ~, +@, -@, [], []= (the last takes two arguments) body ScriptError LoadError, NameError, SyntaxError, NotImplementedError end Access Restriction SystemExit unless bool-expr [then] body public totally accessable. else Catch and Throw body protected accessable only by instances of class and direct descendants. Even through end catch :label do hasA relationships. (see below) expr expr if bool-expr throw :label private accessable only by instances of class. expr unless bool-expr end case target-expr Restriction used without arguments set the default access control. Used with arguments, sets the access of the named