|
|
Line 6: |
Line 6: |
| | | |
| | | |
− | {| style="border-spacing:0;" | + | {| border=1 |
− | ! <center>Visual Cue</center>
| + | | '''Visual Cue''' |
− | ! <center>Narration</center>
| + | | '''Narration''' |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 1
| + | | Slide 1 |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| <center>Welcome to the Spoken Tutorial on </center> | + | | Welcome to the Spoken Tutorial on '''Hello''' '''Ruby'''! |
− | | + | |
− | <center>'''Hello''' '''Ruby'''!</center>
| + | |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 2
| + | | Slide 2 |
| | | |
| Learning Objectives | | Learning Objectives |
| | | |
− | | + | | In this tutorial we will learn |
− | | + | |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| In this tutorial we will learn
| + | |
| | | |
| * What is '''Ruby'''? | | * What is '''Ruby'''? |
Line 32: |
Line 28: |
| * Commenting | | * Commenting |
| * Difference between '''puts''' and '''print''' | | * Difference between '''puts''' and '''print''' |
− |
| |
− |
| |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 3
| + | | Slide 3 |
| | | |
| System Requirements | | System Requirements |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Here we are using
| + | | Here we are using |
| | | |
| * '''Ubuntu Linux '''version 12.04 | | * '''Ubuntu Linux '''version 12.04 |
| * '''Ruby''' 1.9.3 | | * '''Ruby''' 1.9.3 |
− |
| |
− |
| |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 4
| + | | Slide 4 |
| | | |
| Pre-requisites | | Pre-requisites |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| To follow this tutorial you must be connected to the internet.
| + | | To follow this tutorial you must be connected to the internet. |
| | | |
| You must have knowledge of using '''Terminal '''and '''Text editor '''in '''Linux'''. | | You must have knowledge of using '''Terminal '''and '''Text editor '''in '''Linux'''. |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 5
| + | | Slide 5 |
| | | |
| | | |
| What is Ruby? | | What is Ruby? |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now I will explain what is '''Ruby'''.
| + | | Now I will explain what is '''Ruby'''. |
| | | |
| * '''Ruby''' is an object-oriented, interpreted scripting language.<br/> | | * '''Ruby''' is an object-oriented, interpreted scripting language.<br/> |
Line 66: |
Line 58: |
| | | |
| * It has an elegant syntax that is natural to read and easy to write. | | * It has an elegant syntax that is natural to read and easy to write. |
− |
| |
− |
| |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 6
| + | | Slide 6 |
− | | + | |
| | | |
| Features | | Features |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now let us see some features of '''Ruby'''.
| + | | Now let us see some features of '''Ruby'''. |
− | | + | |
| | | |
| * '''Ruby''' is highly portable. | | * '''Ruby''' is highly portable. |
Line 84: |
Line 72: |
| * You can start writing your program from any line and column. | | * You can start writing your program from any line and column. |
| * '''Ruby''' is used for developing Internet and Intra-net applications.<br/> | | * '''Ruby''' is used for developing Internet and Intra-net applications.<br/> |
− |
| |
− |
| |
− |
| |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 7
| + | | Slide 7 |
− | | + | |
| | | |
| RubyGems | | RubyGems |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| One of the most important feature of '''Ruby''' is '''RubyGems'''.
| + | | One of the most important feature of '''Ruby''' is '''RubyGems'''. |
− | | + | |
| | | |
| '''RubyGems''' is a package manager for the '''Ruby''' programming language. | | '''RubyGems''' is a package manager for the '''Ruby''' programming language. |
− |
| |
| | | |
| It provides a standard format for distributing''' Ruby''' programs and libraries. | | It provides a standard format for distributing''' Ruby''' programs and libraries. |
− |
| |
| | | |
| You can create and publish your own '''gems. ''' | | You can create and publish your own '''gems. ''' |
| | | |
| For more information on '''RubyGems''' visit the following link. | | For more information on '''RubyGems''' visit the following link. |
− |
| |
− |
| |
− |
| |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 8
| + | | Slide 8 |
− | | + | |
| | | |
| Help on Ruby | | Help on Ruby |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| To get more help on '''Ruby''' you can visit the links shown.
| + | | To get more help on '''Ruby''' you can visit the links shown. |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 9
| + | | Slide 9 |
− | | + | |
| | | |
| Installation | | Installation |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| You can install '''Ruby '''using the '''Ubuntu Software Centre'''.
| + | | You can install '''Ruby '''using the '''Ubuntu Software Centre'''. |
| | | |
| For more information on '''Ubuntu Software Centre''', please refer to the Ubuntu Linux Tutorials on this website. | | For more information on '''Ubuntu Software Centre''', please refer to the Ubuntu Linux Tutorials on this website. |
− |
| |
− |
| |
− |
| |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 10
| + | | Slide 10 |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Other methods for installing '''Ruby '''are as shown in this slide.
| + | | Other methods for installing '''Ruby '''are as shown in this slide. |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 11
| + | | Slide 11 |
− | | + | |
| | | |
| Running Ruby | | Running Ruby |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| '''Ruby code '''can be executed in 3 ways
| + | | '''Ruby code '''can be executed in 3 ways |
| | | |
| * '''Command line ''' | | * '''Command line ''' |
| * '''Interactive Ruby''' | | * '''Interactive Ruby''' |
| * As a '''file'''<br/> | | * As a '''file'''<br/> |
− |
| |
| | | |
| We will go through each method of execution. | | We will go through each method of execution. |
− |
| |
− |
| |
− |
| |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"|
| + | | |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| First let us see how to execute ''''Hello World'''' code from the command line.
| + | | First let us see how to execute ''''Hello World'''' code from the command line. |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Switch to Terminal
| + | | Switch to Terminal |
| | | |
| Press '''Ctrl+Alt+t''' | | Press '''Ctrl+Alt+t''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Open a terminal by pressing the '''Ctrl, Alt and T '''keys simultaneously.
| + | | Open a terminal by pressing the '''Ctrl, Alt and T '''keys simultaneously. |
− | | + | |
| | | |
| A terminal window appears on your screen. | | A terminal window appears on your screen. |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Type
| + | | Type |
| | | |
| '''<nowiki>ruby -e 'puts ”Hello World”'<<</nowiki>'''press''' Enter''' | | '''<nowiki>ruby -e 'puts ”Hello World”'<<</nowiki>'''press''' Enter''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type the command
| + | | Type the command |
| | | |
| '''ruby '''''space''''' ''hyphen ''e '''''space'' within single quotes '''puts '''space''' '''then within double quotes''' Hello World''' and | | '''ruby '''''space''''' ''hyphen ''e '''''space'' within single quotes '''puts '''space''' '''then within double quotes''' Hello World''' and |
− |
| |
| | | |
| Press '''Enter.''' | | Press '''Enter.''' |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight''' Hello world'''
| + | | Highlight''' Hello world''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| We get the output as '''Hello World.'''
| + | | We get the output as '''Hello World.''' |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight '''puts'''
| + | | Highlight '''puts''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| '''puts '''command''' '''is used to print the output on the '''terminal.'''
| + | | '''puts '''command''' '''is used to print the output on the '''terminal.''' |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight '''-e'''
| + | | Highlight '''-e''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| The'' hyphen'' '''e flag '''allows only a single line of code to be executed.
| + | | The'' hyphen'' '''e flag '''allows only a single line of code to be executed. |
| | | |
| Multiple''' '''''hyphen''''' e flags''' can be used to execute multiple line commands. | | Multiple''' '''''hyphen''''' e flags''' can be used to execute multiple line commands. |
− |
| |
| | | |
| Lets try this out | | Lets try this out |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Press Up Arrow key
| + | | Press Up Arrow key |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now press the up Arrow key to get the previous command and
| + | | Now press the up Arrow key to get the previous command and |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Type
| + | | Type |
| | | |
| ruby -e 'puts “Hello World”'''<nowiki>' -e 'puts 1+2'<< </nowiki>'''Press''' Enter''' | | ruby -e 'puts “Hello World”'''<nowiki>' -e 'puts 1+2'<< </nowiki>'''Press''' Enter''' |
| | | |
− | | + | | Type |
− | | + | |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type
| + | |
| | | |
| ''space''' hypen ''e '''''space ''within'' ''single quotes '''puts '''space '''1+2 '''and | | ''space''' hypen ''e '''''space ''within'' ''single quotes '''puts '''space '''1+2 '''and |
− |
| |
| | | |
| Press''' Enter.''' | | Press''' Enter.''' |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight
| + | | Highlight |
| | | |
| '''Hello World '''and '''3''' | | '''Hello World '''and '''3''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| We get the output as '''Hello World '''and''' 3.'''
| + | | We get the output as '''Hello World '''and''' 3.''' |
− | | + | |
| | | |
| Let's switch back to our slide | | Let's switch back to our slide |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 11
| + | | Slide 11 |
− | | + | |
| | | |
| Interactive Ruby | | Interactive Ruby |
| | | |
− | | + | | We will now learn about '''Interactive Ruby.''' |
− | | + | |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| We will now learn about '''Interactive Ruby.'''
| + | |
− | | + | |
| | | |
| '''Interactive Ruby '''allows the execution of '''Ruby''' commands with immediate response. | | '''Interactive Ruby '''allows the execution of '''Ruby''' commands with immediate response. |
− |
| |
| | | |
| You can run '''Ruby''' statements and examine the output and return values. | | You can run '''Ruby''' statements and examine the output and return values. |
− |
| |
| | | |
| For older version of '''Ruby,''' install '''irb''' separately. | | For older version of '''Ruby,''' install '''irb''' separately. |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Switch to the Terminal
| + | | Switch to the Terminal |
− | | + | |
| | | |
| Type '''irb'''<nowiki><< press </nowiki>'''Enter''' | | Type '''irb'''<nowiki><< press </nowiki>'''Enter''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now let us execute our '''Ruby''' code through '''irb.'''
| + | | Now let us execute our '''Ruby''' code through '''irb.''' |
| | | |
− | Go to the terminal | + | Go to the terminal. |
| | | |
− | | + | Type '''irb '''and press '''Enter''' to launch '''Interactive Ruby'''. |
− | Type | + | |
− | | + | |
− | '''irb '''and | + | |
− | | + | |
− | Press '''Enter.'''
| + | |
− | | + | |
− | To launch '''Interactive Ruby'''
| + | |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Type '''puts ”Hello World”'''<nowiki> <<Press </nowiki>'''Enter'''
| + | | Type '''puts ”Hello World”'''<nowiki> <<Press </nowiki>'''Enter''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type '''puts '''space''' '''within double quotes '''Hello World''' and press '''Enter.'''
| + | | Type '''puts '''space''' '''within double quotes '''Hello World''' and press '''Enter.''' |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight '''Hello World''' and '''nil'''
| + | | Highlight '''Hello World''' and '''nil''' |
− | | + | |
− | | + | |
− | | + | |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| We get the output as '''Hello World.'''
| + | |
− | | + | |
− | And We get the return value as '''nil.'''
| + | |
− | | + | |
| | | |
| + | | We get the output as '''Hello World.''' |
| | | |
| + | And we get the return value as '''nil.''' |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Type '''exit '''<nowiki><<Press</nowiki>''' Enter'''
| + | | Type '''exit '''<nowiki><<Press</nowiki>''' Enter''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| To''' '''exit from '''irb '''type '''exit''' and press '''Enter.'''
| + | | To''' '''exit from '''irb '''type '''exit''' and press '''Enter.''' |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"|
| + | | |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| You can also run '''Ruby program''' from a file.
| + | | You can also run '''Ruby program''' from a file. |
− | | + | |
| | | |
| You can use any text editor of your choice to write the code. | | You can use any text editor of your choice to write the code. |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Switch to text editor
| + | | Switch to text editor |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| I am using '''gedit '''text editor'''.'''
| + | | I am using '''gedit '''text editor'''.''' |
| | | |
| Let me switch to '''gedit''' text editor'''.''' | | Let me switch to '''gedit''' text editor'''.''' |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Type '''puts ”Hello World ”'''
| + | | Type '''puts ”Hello World ”''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now, type '''puts''' space within double quotes''' Hello World '''
| + | | Now, type '''puts''' space within double quotes''' Hello World ''' |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"|
| + | | |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Lets learn how to add multiple line or block '''comments'''.
| + | | Lets learn how to add multiple line or block '''comments'''. |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Type '''<nowiki>=begin <<</nowiki>'''press''' Enter'''
| + | | Type '''<nowiki>=begin <<</nowiki>'''press''' Enter''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Before the '''puts '''command
| + | | Before the '''puts '''command |
| | | |
| Type, | | Type, |
Line 304: |
Line 245: |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight '''<nowiki>=begin</nowiki>'''
| + | | Highlight '''<nowiki>=begin</nowiki>''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| ''Equal to '''''begin '''is used to start the comment.
| + | | ''Equal to '''''begin '''is used to start the comment. |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Type
| + | | Type |
− | | + | |
| | | |
| '''My first Ruby program''' | | '''My first Ruby program''' |
Line 316: |
Line 256: |
| | | |
| '''Press Enter ''' | | '''Press Enter ''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type the comments that you wish to add.
| + | | Type the comments that you wish to add. |
− | | + | |
| | | |
| I will type | | I will type |
− |
| |
| | | |
| '''My first Ruby program. Press enter''' | | '''My first Ruby program. Press enter''' |
Line 329: |
Line 267: |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Type
| + | | Type |
| | | |
| '''<nowiki>=end</nowiki>''' | | '''<nowiki>=end</nowiki>''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now type
| + | | Now type |
| | | |
| ''equal to '''''end''' | | ''equal to '''''end''' |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight '''<nowiki>=end</nowiki>'''
| + | | Highlight '''<nowiki>=end</nowiki>''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| ''equal to '''''end '''is used to end multiple line''' comments.'''
| + | | ''equal to '''''end '''is used to end multiple line''' comments.''' |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"|
| + | | |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| '''Comments''' are useful to understand the flow of program.
| + | | '''Comments''' are useful to understand the flow of program. |
| | | |
| It is useful for documentation. | | It is useful for documentation. |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Click on the '''Save''' button
| + | | Click on the '''Save''' button |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now, let us '''save''' the '''file''' by clicking on the '''Save '''button.
| + | | Now, let us '''save''' the '''file''' by clicking on the '''Save '''button. |
− | | + | |
| | | |
| It is a good practice to '''save''' the file frequently. | | It is a good practice to '''save''' the file frequently. |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| In the '''Save As '''dialog box >> Browse the location to save the file
| + | | In the '''Save As '''dialog box >> Browse the location to save the file |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| The '''Save As '''dialog box''' '''appears on your screen.
| + | | The '''Save As '''dialog box''' '''appears on your screen. |
| | | |
| Browse the location where you want to save the file. | | Browse the location where you want to save the file. |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Create a folder named '''rubyprogram '''on the '''Desktop'''.
| + | | Create a folder named '''rubyprogram '''on the '''Desktop'''. |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| On '''Desktop, '''I will create a folder named '''rubyprogram'''.
| + | | On '''Desktop, '''I will create a folder named '''rubyprogram'''. |
| | | |
| | | |
Line 367: |
Line 304: |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| In '''Name''' text-box >> type
| + | | In '''Name''' text-box >> type |
| | | |
| '''hello.rb''' | | '''hello.rb''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| In the '''Name''' text-box, type the name that you wish to add.
| + | | In the '''Name''' text-box, type the name that you wish to add. |
| | | |
| I will type '''hello.rb''' | | I will type '''hello.rb''' |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Point to '''Dot rb''' extension
| + | | Point to '''Dot rb''' extension |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| '''Dot rb''' extension is given to a '''Ruby '''file
| + | | '''Dot rb''' extension is given to a '''Ruby '''file |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Click on '''Save''' button
| + | | Click on '''Save''' button |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Then click on '''Save '''button to save the file.
| + | | Then click on '''Save '''button to save the file. |
| | | |
| So the file is saved now. | | So the file is saved now. |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Switch to the '''terminal.''' | + | | Switch to the '''terminal.''' |
| + | | To execute the code, go to the '''terminal.''' |
| | | |
− | | + | Lets clear the '''terminal''' first. |
− | | + | |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| To execute the code, go to the '''terminal.'''
| + | |
− | | + | |
− | Lets clear the terminal first.
| + | |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"|
| + | | |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Make sure that you are in the directory where your '''Ruby '''file is present.
| + | | Make sure that you are in the directory where your '''Ruby '''file is present. |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"|
| + | | |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Remember that we are in the '''home '''directory. We need to go to the subdirectory '''rubyprogram'''.
| + | | Remember that we are in the '''home '''directory. We need to go to the subdirectory '''rubyprogram'''. |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Type '''cd Desktop/rubyprogram'''<nowiki><< Press </nowiki>'''Enter'''
| + | | Type '''cd Desktop/rubyprogram'''<nowiki><< Press </nowiki>'''Enter''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| To do so, type '''''cd '''''space'' '''''Desktop/rubyprogram'' '''''and press'' '''''Enter.'''
| + | | To do so, type '''''cd '''''space'' '''''Desktop/rubyprogram'' '''''and press'' '''''Enter.''' |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Type''' ruby hello.rb'''<nowiki> <<Press </nowiki>'''Enter'''
| + | | Type''' ruby hello.rb'''<nowiki> <<Press </nowiki>'''Enter''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let's execute the file
| + | | Let's execute the file |
| | | |
| Type '''ruby space hello dot rb''' and press '''Enter''' | | Type '''ruby space hello dot rb''' and press '''Enter''' |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight '''HelloWorld '''
| + | | Highlight '''HelloWorld ''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| We get the output '''HelloWorld.'''
| + | | We get the output '''HelloWorld.''' |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"|
| + | | |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now let me demonstrate the difference between '''puts''' and '''print '''statement.
| + | | Now let me demonstrate the difference between '''puts''' and '''print '''statement. |
− | | + | |
| | | |
| We will try this out using''' irb''' | | We will try this out using''' irb''' |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Type
| + | | Type |
| | | |
| '''cd'''<nowiki> <<press </nowiki>'''Enter''' | | '''cd'''<nowiki> <<press </nowiki>'''Enter''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Before that we need to go back to the home directory
| + | | Before that we need to go back to the home directory |
| | | |
| To do so type '''cd '''and press '''Enter''' | | To do so type '''cd '''and press '''Enter''' |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| In the terminal
| + | | In the terminal |
| | | |
| Type '''irb'''<nowiki><< press </nowiki>'''Enter''' | | Type '''irb'''<nowiki><< press </nowiki>'''Enter''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now type''' '''
| + | | Now type''' ''' |
| | | |
| '''irb and Press Enter''' | | '''irb and Press Enter''' |
Line 441: |
Line 374: |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Type '''puts “Hello”,”World” '''
| + | | Type '''puts “Hello”,”World” ''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type
| + | | Type |
| | | |
| '''puts '''space''' '''within double quotes '''Hello '''comma within double quotes '''World ''' | | '''puts '''space''' '''within double quotes '''Hello '''comma within double quotes '''World ''' |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight or point to '''comma'''
| + | | Highlight or point to '''comma''' |
| | | |
| '''Press Enter''' | | '''Press Enter''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Here''' comma '''is used to join the two '''puts''' command together.
| + | | Here''' comma '''is used to join the two '''puts''' command together. |
| | | |
| Now press '''Enter.''' | | Now press '''Enter.''' |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight '''Hello World'''
| + | | Highlight '''Hello World''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| We get the output '''Hello World,''' but on separate lines.
| + | | We get the output '''Hello World,''' but on separate lines. |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Type '''print '''“Hello”,”World”
| + | | Type '''print '''“Hello”,”World” |
| | | |
| <nowiki><<Press </nowiki>'''Enter''' | | <nowiki><<Press </nowiki>'''Enter''' |
| | | |
− | | + | | Now let's try the same thing with '''print.''' |
− | | + | |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now let's try the same thing with '''print.'''
| + | |
− | | + | |
| | | |
| Press up arrow key to get the previous command | | Press up arrow key to get the previous command |
Line 475: |
Line 405: |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight '''HelloWorld'''
| + | | Highlight '''HelloWorld''' |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| We get the output''' as Hello World '''but on the same line.
| + | | We get the output''' as Hello World '''but on the same line. |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"|
| + | | |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| The keyword '''puts''' adds a newline to the end of the output. The keyword''' print '''does not.
| + | | The keyword '''puts''' adds a newline to the end of the output. The keyword''' print '''does not. |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"|
| + | | |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| The keyword''' print '''outputs only what we have provided.
| + | | The keyword''' print '''outputs only what we have provided. |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"|
| + | | |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| <nowiki><<Pause>></nowiki>
| + | | <nowiki><<Pause>></nowiki> |
| | | |
| This brings us to the end of this Spoken Tutorial. | | This brings us to the end of this Spoken Tutorial. |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 11
| + | | Slide 11 |
| | | |
| | | |
| Summary | | Summary |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| In this tutorial we have learnt
| + | | In this tutorial we have learnt |
| | | |
| * About '''Ruby''' | | * About '''Ruby''' |
Line 511: |
Line 441: |
| | | |
| * Difference between '''puts''' and '''print''' | | * Difference between '''puts''' and '''print''' |
− |
| |
− |
| |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 13
| + | | Slide 13 |
| | | |
| Assignment | | Assignment |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| As an assignment
| + | | As an assignment |
| | | |
| Write a program to print your name and age | | Write a program to print your name and age |
Line 531: |
Line 459: |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 14
| + | | Slide 14 |
| | | |
| About the Spoken Tutorial Project | | About the Spoken Tutorial Project |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Watch the video available at the following link.
| + | | Watch the video available at the following link. |
| | | |
| | | |
Line 542: |
Line 470: |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 15
| + | | Slide 15 |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| The Spoken Tutorial Project Team :
| + | | The Spoken Tutorial Project Team : |
| | | |
| | | |
Line 555: |
Line 483: |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 16
| + | | Slide 16 |
− | | + | |
| | | |
| Acknowledgement | | Acknowledgement |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Spoken Tutorial Project is a part of the Talk to a Teacher project.
| |
| | | |
− | It is supported by the National Mission on Education through ICT, MHRD, Government of India. | + | |Spoken Tutorial Project is a part of the Talk to a Teacher project. |
| + | |
| + | It is supported by the National Mission on Education through ICT, |
| + | |
| + | MHRD, Government of India. |
| | | |
| More information on this Mission is available at below link: | | More information on this Mission is available at below link: |
Line 568: |
Line 498: |
| | | |
| |- | | |- |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| NO SLIDE
| + | | NO SLIDE |
| | | |
| On the previous slide itself. | | On the previous slide itself. |
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| This is Afrin Pinjari from IIT Bombay, signing off.
| + | | This is Afrin Pinjari from IIT Bombay, signing off. |
| | | |
| Thank you for watching. | | Thank you for watching. |
| | | |
| |} | | |} |
Visual Cue
|
Narration
|
Slide 1
|
Welcome to the Spoken Tutorial on Hello Ruby!
|
Slide 2
Learning Objectives
|
In this tutorial we will learn
- What is Ruby?
- Features
- RubyGems & Help on Ruby
- Installation
- Running Ruby code
- Commenting
- Difference between puts and print
|
Slide 3
System Requirements
|
Here we are using
- Ubuntu Linux version 12.04
- Ruby 1.9.3
|
Slide 4
Pre-requisites
|
To follow this tutorial you must be connected to the internet.
You must have knowledge of using Terminal and Text editor in Linux.
|
Slide 5
What is Ruby?
|
Now I will explain what is Ruby.
- Ruby is an object-oriented, interpreted scripting language.
- It is dynamic, open source programming language.
- It has an elegant syntax that is natural to read and easy to write.
|
Slide 6
Features
|
Now let us see some features of Ruby.
- Ruby is highly portable.
- Ruby program runs in any operating system.
- Variables in Ruby have no datatype, such as in Smalltalk, BASIC or Python.
- It supports automatic memory management.
- Ruby is free format language.
- You can start writing your program from any line and column.
- Ruby is used for developing Internet and Intra-net applications.
|
Slide 7
RubyGems
|
One of the most important feature of Ruby is RubyGems.
RubyGems is a package manager for the Ruby programming language.
It provides a standard format for distributing Ruby programs and libraries.
You can create and publish your own gems.
For more information on RubyGems visit the following link.
|
Slide 8
Help on Ruby
|
To get more help on Ruby you can visit the links shown.
|
Slide 9
Installation
|
You can install Ruby using the Ubuntu Software Centre.
For more information on Ubuntu Software Centre, please refer to the Ubuntu Linux Tutorials on this website.
|
Slide 10
|
Other methods for installing Ruby are as shown in this slide.
|
Slide 11
Running Ruby
|
Ruby code can be executed in 3 ways
- Command line
- Interactive Ruby
- As a file
We will go through each method of execution.
|
|
First let us see how to execute 'Hello World' code from the command line.
|
Switch to Terminal
Press Ctrl+Alt+t
|
Open a terminal by pressing the Ctrl, Alt and T keys simultaneously.
A terminal window appears on your screen.
|
Type
ruby -e 'puts ”Hello World”'<<press Enter
|
Type the command
ruby space hyphen e space within single quotes puts space then within double quotes Hello World and
Press Enter.
|
Highlight Hello world
|
We get the output as Hello World.
|
Highlight puts
|
puts command is used to print the output on the terminal.
|
Highlight -e
|
The hyphen e flag allows only a single line of code to be executed.
Multiple hyphen e flags can be used to execute multiple line commands.
Lets try this out
|
Press Up Arrow key
|
Now press the up Arrow key to get the previous command and
|
Type
ruby -e 'puts “Hello World”' -e 'puts 1+2'<< Press Enter
|
Type
space hypen e space within single quotes puts space 1+2 and
Press Enter.
|
Highlight
Hello World and 3
|
We get the output as Hello World and 3.
Let's switch back to our slide
|
Slide 11
Interactive Ruby
|
We will now learn about Interactive Ruby.
Interactive Ruby allows the execution of Ruby commands with immediate response.
You can run Ruby statements and examine the output and return values.
For older version of Ruby, install irb separately.
|
Switch to the Terminal
Type irb<< press Enter
|
Now let us execute our Ruby code through irb.
Go to the terminal.
Type irb and press Enter to launch Interactive Ruby.
|
Type puts ”Hello World” <<Press Enter
|
Type puts space within double quotes Hello World and press Enter.
|
Highlight Hello World and nil
|
We get the output as Hello World.
And we get the return value as nil.
|
Type exit <<Press Enter
|
To exit from irb type exit and press Enter.
|
|
You can also run Ruby program from a file.
You can use any text editor of your choice to write the code.
|
Switch to text editor
|
I am using gedit text editor.
Let me switch to gedit text editor.
|
Type puts ”Hello World ”
|
Now, type puts space within double quotes Hello World
|
|
Lets learn how to add multiple line or block comments.
|
Type =begin <<press Enter
|
Before the puts command
Type,
equal to begin and press Enter
|
Highlight =begin
|
Equal to begin is used to start the comment.
|
Type
My first Ruby program
This code will print Hello world
Press Enter
|
Type the comments that you wish to add.
I will type
My first Ruby program. Press enter
This code will print Hello world.
Press Enter
|
Type
=end
|
Now type
equal to end
|
Highlight =end
|
equal to end is used to end multiple line comments.
|
|
Comments are useful to understand the flow of program.
It is useful for documentation.
|
Click on the Save button
|
Now, let us save the file by clicking on the Save button.
It is a good practice to save the file frequently.
|
In the Save As dialog box >> Browse the location to save the file
|
The Save As dialog box appears on your screen.
Browse the location where you want to save the file.
|
Create a folder named rubyprogram on the Desktop.
|
On Desktop, I will create a folder named rubyprogram.
We will save the file inside this folder.
|
In Name text-box >> type
hello.rb
|
In the Name text-box, type the name that you wish to add.
I will type hello.rb
|
Point to Dot rb extension
|
Dot rb extension is given to a Ruby file
|
Click on Save button
|
Then click on Save button to save the file.
So the file is saved now.
|
Switch to the terminal.
|
To execute the code, go to the terminal.
Lets clear the terminal first.
|
|
Make sure that you are in the directory where your Ruby file is present.
|
|
Remember that we are in the home directory. We need to go to the subdirectory rubyprogram.
|
Type cd Desktop/rubyprogram<< Press Enter
|
To do so, type cd space Desktop/rubyprogram and press Enter.
|
Type ruby hello.rb <<Press Enter
|
Let's execute the file
Type ruby space hello dot rb and press Enter
|
Highlight HelloWorld
|
We get the output HelloWorld.
|
|
Now let me demonstrate the difference between puts and print statement.
We will try this out using irb
|
Type
cd <<press Enter
|
Before that we need to go back to the home directory
To do so type cd and press Enter
|
In the terminal
Type irb<< press Enter
|
Now type
irb and Press Enter
to launch the Interactive Ruby.
|
Type puts “Hello”,”World”
|
Type
puts space within double quotes Hello comma within double quotes World
|
Highlight or point to comma
Press Enter
|
Here comma is used to join the two puts command together.
Now press Enter.
|
Highlight Hello World
|
We get the output Hello World, but on separate lines.
|
Type print “Hello”,”World”
<<Press Enter
|
Now let's try the same thing with print.
Press up arrow key to get the previous command
Replace puts with print and
Press Enter.
|
Highlight HelloWorld
|
We get the output as Hello World but on the same line.
|
|
The keyword puts adds a newline to the end of the output. The keyword print does not.
|
|
The keyword print outputs only what we have provided.
|
|
<<Pause>>
This brings us to the end of this Spoken Tutorial.
|
Slide 11
Summary
|
In this tutorial we have learnt
- About Ruby
- Installation
- Execution of Ruby code
- Adding multiple comments
=begin
......
=end
- Difference between puts and print
|
Slide 13
Assignment
|
As an assignment
Write a program to print your name and age
We used multiple line comments in this tutorial
Try to give single line comment
Hint:
#...............
|
Slide 14
About the Spoken Tutorial Project
|
Watch the video available at the following link.
It summarises the Spoken Tutorial project.
If you do not have good bandwidth, you can download and watch it.
|
Slide 15
|
The Spoken Tutorial Project Team :
Conducts workshops using spoken tutorials
Gives certificates to those who pass an online test
For more details, please write to
contact@spoken-tutorial.org
|
Slide 16
Acknowledgement
|
Spoken Tutorial Project is a part of the Talk to a Teacher project.
It is supported by the National Mission on Education through ICT,
MHRD, Government of India.
More information on this Mission is available at below link:
spoken-tutorial.org/NMEICT-Intro.
|
NO SLIDE
On the previous slide itself.
|
This is Afrin Pinjari from IIT Bombay, signing off.
Thank you for watching.
|