Saturday, 5 August 2017

RUBY ON RAILS


Ruby:

Open source.
Developed by Yukihiro "Martz" Matsumoto in mid 1990s in Japan.
Current Ruby version 2.4.0 was released on 25thDecember 2016.
Downloading:
Open google and download ruby installer.
After downloading we can see in downloads it has been successfully downloaded now can install it.

Accept the license agreement and click on next.

Click on install process.

Ruby has been successfully installed now click on finish.

We can see command prompt.

Click on next to continue.

Click on next.

Installing 64 bit for windows.


Now, right click on properties and open.

Click on advanced system settings. 
Click on Environment variables. 
Set path and variable value. Click on ok. 
After setting path write the program.
Hello Ruby program:
Variables:
Location which holds data.
No need to declare a variable in ruby.
Prefix is needed to indicate it.
Types:


Data Types:
Represents a type of data such as text, string, numbers etc.
Different datatypes:
String:
Textual data.
Eg:p "Ruby"
Symbols:
Represent objects.
Hashes:
Key value pairs.
Array:
Collection of object.
Boolean:
True or false.
Eg:bool=[true, false]
Loops:
for:
Iterates over a specific range of numbers.
Used if a program has fixed number of iterations.
Syntax:
for variable [, variable ...] in expression [do]  
code  
end 

Eg:
while:
Used to iterate a program several times.
Number of iterations is not fixed for a program.
Syntax:
while conditional [do]  
code  
end

Eg:
do-while:
Loop will execute atleast once. Because condition is written at the end of the code.
Syntax:
loop do   
#code to be executed  
break if booleanExpression  
end 
 

Conditional statements:
if:
if block statement is executed if the condition is true.
Syntax:
if(condition)  
//code to be executed

end
Flowchart:
Eg:
if else:
If condition is true if block statement is executed otherwise else block statement is executed.
Syntax:
if(condition)  
//code if condition is true  
else  
//code if condition is false  
end  
Flowchart:
Eg:
if else if(elsif):
if block statement is executed if condition is true otherwise else block statement is executed.
Syntax:
if(condition1)  
//code to be executed if condition1 is true  
elsif (condition2)  
//code to be executed if condition2 is true  
else (condition3)  
//code to be executed if condition3 is true  
end  

Flowchart:
Eg:
String expressions:
Ruby string literals are enclosed within single and double quotes.
Eg:
puts 'Hello everyone'   
puts "Hello everyone" 
Add two strings:
Partial string:
Find the starting point of a string:
Count the number of occurances of a substring in a string:
Read from user input and write to user output:
Read from a file and write to a file:
Reading a file:
First create a .txt file and save it.

Open computer and local disk c open it.
Open users. 
In this we can see vinay folder. 
Now, copy the .txt file in the vinay folder. 
Now, we can see after copying our .txt file. 
Now, in our program we are specifying the text file name as Moulica and we are writing our code.


Writing a file:
Now open local disk c and we can see the data in that created text file.



We can see the output which it appears in my text file.
Downloading Ruby on Rails:





Set path go to c drive then rails installer then copy till bin folder and click ok.
Ravi replace with chandu:
First non repeated character in a string:
Permutation of a string:
%w-uses space to seperate each value.
&-Used to denote arguments.
join-used to join.
Digit identification if string has any number or not:
Highest repeated character:
Database: