SCRIPTING IN RUBY By Amber Bennett “Ruby is simple in appearance, but is very complex inside, just like our human body.” --Yukihiro Matsumoto.

Slides:



Advertisements
Similar presentations
Variables in C Amir Haider Lecturer.
Advertisements

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Introduction to Ruby.
John Pinney Ruby in 20 minutes John Pinney
 Computer Science 1MD3 Introduction to Programming Winter 2014.
Names and Bindings.
Ruby: An introduction - Who am I? Maciej Mensfeld Presented by: Maciej Mensfeld Ruby: An introduction dev.mensfeld.pl github.com/mensfeld.
Primitive Data Types There are a number of common objects we encounter and are treated specially by almost any programming language These are called basic.
CSE Winter 2008 Introduction to Program Verification symbolic execution continued.
CS 898N – Advanced World Wide Web Technologies Lecture 8: PERL Chin-Chih Chang
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
Ruby The Gem of new programming languages. An interpreted scripting language.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
Page 1 Ruby by Tim Hanson & Mamadou Seck. Page 2 Philosophy "I hope to see Ruby help every programmer in the world to be productive, and to enjoy programming,
Guide To UNIX Using Linux Third Edition
String Escape Sequences
The Ruby Programming Language
Chapter 4 – The Building Blocks Data Types Literals Variables Constants.
4. Python - Basic Operators
A TOUR OF RUBY 2011 ACM Class, Dong Xie. What is Ruby?  Dynamic programming language  Complex but expressive grammar  A core class library with rich.
Chapter 8 High-Level Programming Languages (modified by Erin Chambers)
1 Perl Perl basics Perl Elements Arrays and Hashes Control statements Operators OOP in Perl.
School of Computing and Information Systems CS 371 Web Application Programming PHP - Basics Serving up web pages.
CPTR 124 Review for Test 1. Development Tools Editor Similar to a word processor Allows programmer to compose/save/edit source code Compiler/interpreter.
Michael Musick CSC 415. A Brief History of bash  Language was named in tribute to Steve Bourne’s shell  Brian Fox wrote the first versions of bash 
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
November 2003Bent Thomsen - FIT 6-11 IT – som værktøj Bent Thomsen Institut for Datalogi Aalborg Universitet.
JAVA Tokens. Introduction A token is an individual element in a program. More than one token can appear in a single line separated by white spaces.
4 1 Array and Hash Variables CGI/Perl Programming By Diane Zak.
/* Documentations */ Pre process / Linking statements Global declarations; main( ) { Local Declarations; Program statements / Executable statements; }
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
A very basic overview of Server-Side Scripting Or what is PHP, Perl, Python, Ruby and what can they do for me?
Trends in Scripting Languages History For me the purpose of life is partly to have joy. Programmers often feel joy when they can concentrate on the creative.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
VBScript Language. What is VBScript Based on the Visual Basic family of languages Supports object oriented features Interpreted Loosely Typed Implicitly.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 2: Variables & Data Types.
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
VARIABLES, CONSTANTS, OPERATORS ANS EXPRESSION
Python Primer 1: Types and Operators © 2013 Goodrich, Tamassia, Goldwasser1Python Primer.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
RUBY by Ryan Chase.
IT ELECTIVE 2.  Web server Can refer to either the hardware (the computer) or the software (the computer application) that helps to deliver content that.
Scripting Languages Diana Trandab ă ț Master in Computational Linguistics - 1 st year
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
Scripting with Ruby What is a scripting language? What is Ruby?
Introduction to Perl. What is Perl Perl is an interpreted language. This means you run it through an interpreter, not a compiler. Similar to shell script.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
General Computer Science for Engineers CISC 106 Lecture 12 James Atlas Computer and Information Sciences 08/03/2009.
FP512 WEB PROGRAMMING 1 PREPARED BY: PN. NUR SYUHADA BINTI MOHAMAD.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
1 Getting Started with Ruby. 2 What’s Ruby? Ruby is an OO, dynamic, agile language –Everything’s an object For example, try puts -1.abs –Derives strengths.
Session 2: PHP Language Basics iNET Academy Open Source Web Development.
Introduction to information systems RUBY dr inż. Tomasz Pieciukiewicz.
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
Ruby Tien Ho and Brandon Hostetter. Overview ▸ Object-oriented, functional, imperative, and reflective ▸ Interpreted language ▸ Influenced by Perl, Smalltalk,
Ruby: An Introduction Created by Yukihiro Matsumoto in 1993 (named after his birthstone) Pure OO language (even the number 1 is an instance of a class)
Scope History of Ruby. Where can you use Ruby? General Features.
CS 371 Web Application Programming
Introduction Python is an interpreted, object-oriented and high-level programming language, which is different from a compiled one like C/C++/Java. Its.
Variables, Expressions, and IO
Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. It was created by Guido van Rossum during.
JavaScript: Control Statements I
Chapter 19 JavaScript.
What to do today: Brief history of Ruby General qualities/info
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A,
Introduction to Python
Ruby Testing 2, 11/9/2004.
Web Programming and Design
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

SCRIPTING IN RUBY By Amber Bennett “Ruby is simple in appearance, but is very complex inside, just like our human body.” --Yukihiro Matsumoto

HISTORY  Created by Yukihiro Matsumoto  Initial release in 1995  Matsumoto desired a scripting language with object-oriented support Photo Credit: "Yukihiro Matsumoto EuRuKo 2011" by Mathias Meyer - Licensed under Creative Commons Attribution-Share Alike 2.0 via Wikimedia Commons -

NAMES, BINDINGS, AND SCOPES  Variable names can start with numbers, letters, and any combination of the two  They must start with a letter or an underscore  Variable names are descriptive  Case sensitivity:  Class names must be capitalized  Variable names are begun with lowercase letters

 Class variables  Exist in the scope of a class  Instance variables  Unique to a given instance of a class  Constants  Do not change throughout execution of a program  Can be reassigned, but interpreter will give a warning

DATA TYPES  Dynamically typed  Class variables start with  Instance variables start  Constants begin with a capital letter  String type  Number type  Symbols  Arrays and Hashes  Abstract Data Types  Provided through classes in Ruby

STRINGS: THE DIFFERENCE BETWEEN SINGLE AND DOUBLE QUOTES Double QuotesSingle Quotes  The code sample: “The time is #{Time.now}”  Prints out: The time is :26:  The code sample: ‘The time is #{Time.now};  Prints out: The time is \#{Time.now}

SYMBOLS 1. # p039xysymbol.rb 2. know_ruby = :yes 3. if know_ruby == :yes 4. puts 'You are a Rubyist' 5. else 6. puts 'Start learning Ruby' 7. end Source:

ARRAYS AND HASHES  Common among other languages  0 indexed  Arrays are defined by []  Hashes are defined by curly braces in the format: hash_name = { :key1 => “value1”, :key2 => “value2” }

EXPRESSIONS AND ASSIGNMENT STATEMENTS  Operators  [] []=Assignment  * / % + **Arithmetic  Comparison .. …Range  & ^ |AND, XOR, regular OR (bitwise)  || && not or andLogical operators  Ternary operator:  expression ? value_if_true : value_if_false

STATEMENT-LEVEL CONTROL STRUCTURES  If-statements  Then, else, end  Case Expressions  Blocks 1. if sum == 0 then 2. if count == 0 then 3. result = 0 4. end 5. else 6. result = 1 7. end

CASE EXPRESSIONS

OBJECT-ORIENTED SUPPORT  Matsumoto created Ruby with object-oriented support in mind  A lot of functionality when dealing with files  Matsumoto “wanted a scripting language that was more powerful than Perl, and more object-oriented than Python.” Video!

CONCURRENCY AND EXCEPTION AND EVENT HANDLING  Logical concurrency  Global Interpreter Lock (GIL)  Exceptions can be caught using “rescue”

SOURCES  Code samples taken from (unless otherwise specified): 