SlideShare una empresa de Scribd logo
1 de 16
Descargar para leer sin conexión
Ruby	on	Rails	
                                                #2	Ruby	


                               	
                               	
                                       helper2424@gmail.com	   1
What	is	Ruby	
• Programing	language	
• Dynamic	
• Multi‑paradigm:	OOP,	functional,	                                           	
                                                                              		


	imperative,	reflection	
• Influenced	by:	Perl,	Smalltalk,	Lisp,		
C++,	Python	...	
• Created	in	the	mid‑1990s	
• "I	wanted	a	scripting	language	that	was	more		 Yukihiro	Matsumoto	(Japan)
                                                                         	
                                                                         		


powerful	than	Perl,	and	more	object‑oriented	than	Python.	That's	why	
I	decided	to	design	my	own	language."		                            			

                                                      helper2424@gmail.com	    2
Deeper	in	the	Ruby	
             	




•   Latest	stable	version	1.9.3‑p286	
•   RoR	3.0	has	bugs	with	Ruby	1.8.7	p248	and	p249	
•   RoR	3.0	has	conflicts	with	1.9.1	                           	
                                                                		


•   Use	RoR	3.x	with	Ruby	1.9.>=2	
•   Ruby	License	
    	
    	
                                                                	
                                                                		




                                                          			

                                        helper2424@gmail.com	    4
Philosophy	
• Everything	is	object	(numbers,	primitives,	
  methods	and	classes	too)	
• Every	object	has	class	and	superclass		
                                                                  	
                                                                  		

• The	root	of	class	hierarchy	is	Object		
• Ruby	has	not	static	methods	or	variables	
• All	instance	variables	are	private		
• Interfacejava	mechanism	through	modules	
                                                                  	
                                                                  		
• Module	(like	class,	but)	has	not	variables	
  	                                                          		
                                                             	



  	                                       helper2424@gmail.com	    5
Hello	world	
#!/usr/bin/ruby	                       #!/usr/bin/ruby	
                                       #	coding:	utf‑8
#	coding:	utf‑8	
	                                      def	hello_world();
puts	"Hello	World!"	                   								puts	"Hello	world";
                                       end;                                   	
                                                                              		



                                       hello_world();	
 #!/usr/bin/ruby	
 #	coding:	utf‑8

 def	hello_world
 								puts	"Hello	world"
 end                                                                          	
                                                                              		



 hello_world
                                                                        			
 	
                                                      helper2424@gmail.com	    3
Ok,	now	install	Ruby	
• http://en.wikibooks.org/wiki/Ruby_Programmin
  g/Installing_Ruby	
• All	examples	work	with		
                                                            	
                                                            		
  Ryby	1.9.3p125	




                                                            	
                                                            		




                                                      			

                                    helper2424@gmail.com	    7
Little	bit	of	syntax	
             	




#One	line	comments	
=begin	multiline	comments	(=begin	and	=end	in	one	
column)	
                                                                   	
                                                                   		

=end	
'It's	string'	and	"It's	string"	and	%q!It's	string	too!	
a	#	variable	
$b	#	global	variable	
                                                                   	
                                                                   		
@c	#	instance	variable	
Constant	#	but	u	can	change	it	if	bribe	conscience	          			

                                           helper2424@gmail.com	    7
Functions	
                             	




def	this_function()	
						#function_body	
end	
	
def	this_function	                                                	
                                                                  		


          #function_body		
end	
	
def	==(variable)	
      #overload	operator	

end	                                                              	
                                                                  		




                                                            			

                                          helper2424@gmail.com	    8
Classes	
                               	




class	Your_class	
						@test	#	by	default	private	
						def	test_method	#by	default	public	
												#code	
						end	                                                               	
                                                                         		

private	#yep,	private	modificator	like	in	C++	
					def	test_method2	#private	
												#code	
					end	
public		
       def	test_method	#	public	
   						#code	                                                          	
                                                                         		

   end	
end	                                                               			

                                                 helper2424@gmail.com	    9
Code	blocks	
def	test	
					print	"<<"	
     yeild	"Wolrd"	                                        	
                                                           		


end	
	
test	do	|x|	
			print	"	Hello	#{x}	!	>>"			
end	                                                       	
                                                           		



#	result	<<	Hello	World	!	>>				                     			

                                   helper2424@gmail.com	   10
Libraries	
• All	through	packages	
• Self	package	system	(gem)	
                                                       	
                                                       		




                                                       	
                                                       		




                                                 			

                               helper2424@gmail.com	   11
Some	features	
• Ruby	has	interactive	interpretator	irb		
• Ruby	slow	with	Windows	(Ruby	isn't	optimized	for	
  windows,	because	most	core	developers	use	Linux)	
                                                                              	
• Interpretator	encoding	is	utf8	                                             		




  	
  	


                                                                              	
                                                                              		




                                                                        			

                                                      helper2424@gmail.com	    9
Links	
• http://www.ruby‑lang.org/en/	‑	Ruby	official	
  site	
• http://en.wikibooks.org/wiki/Ruby_Programmin
                                                                	
                                                                		
  g/Installing_Ruby	‑	install	Ruby	
• http://www.ruby‑doc.org/	‑	documentation	
• http://tryruby.org/	‑	interactive	for	learning	ruby	
  for	beginers	

                                                                	
                                                                		
• http://rubymonk.com/	‑	use	it	after	truruby	(for	
  beginers	too)	                                           		
                                                           	


  	                                     helper2424@gmail.com	   10
Literature	in	RU	
• Michael	Fitzgerald	"Learning	Ruby":	superficial	
• David	Flanagan	and	Yukihiro	Matsumoto	"The	
  Ruby	Programming	Language"	:	detailed	book	
                                                                	
                                                                		

  	




                                                                	
                                                                		




                                                          			

                                        helper2424@gmail.com	   11
Literature	in	EN	
• David	A.	Black	"The	Well‑Grounded	Rubyist"	:	
  good	book	
• Dave	Thomas,	Chad	Fowler,	Andy	Hunt	
                                                              	
                                                              		
  "Programming	Ruby	1.9	(3rd	edition):	The	
  Pragmatic	Programmers'	Guide"	:	good	book	too	



                                                              	
                                                              		




                                                        			

                                      helper2424@gmail.com	   11
Additional	literature	
• Russ	Olsen	"Design	Patterns	In	Ruby"	:	patterns	
  for	rubists	
• 	William	C.	Wake,	Kevin	Rutherford	"Refactoring	
                                                               	
                                                               		
  in	Ruby"	:	all	in	name	
• Jay	Fields,	Shane	Harvie,	Martin	Fowler	
  "Refactoring:	Ruby	Edition"	:	Fowlers's	
  "Refactoring"	with	examples	for	Ruby	

                                                               	
                                                               		




                                                         			

                                       helper2424@gmail.com	   13

Más contenido relacionado

Destacado

Kajang sustainable development
Kajang sustainable developmentKajang sustainable development
Kajang sustainable development
Ali Alshock
 
Link building
Link buildingLink building
Link building
Hani Adel
 
التسويق الالكتروني في كلمتين
التسويق الالكتروني في كلمتينالتسويق الالكتروني في كلمتين
التسويق الالكتروني في كلمتين
Hani Adel
 
Scanor resot
Scanor resotScanor resot
Scanor resot
Hani Adel
 
My home town sustainability
My home town sustainabilityMy home town sustainability
My home town sustainability
Ali Alshock
 
Sustainable urban trans. in hannover
Sustainable urban trans. in hannoverSustainable urban trans. in hannover
Sustainable urban trans. in hannover
Ali Alshock
 

Destacado (17)

Seo OnPage
Seo OnPageSeo OnPage
Seo OnPage
 
PuShort Term Hydrothermal Scheduling using Evolutionary Programmingblished pa...
PuShort Term Hydrothermal Scheduling using Evolutionary Programmingblished pa...PuShort Term Hydrothermal Scheduling using Evolutionary Programmingblished pa...
PuShort Term Hydrothermal Scheduling using Evolutionary Programmingblished pa...
 
Kajang sustainable development
Kajang sustainable developmentKajang sustainable development
Kajang sustainable development
 
Optimal placement of_phasor_measurement_units_using_gravitat
Optimal placement of_phasor_measurement_units_using_gravitatOptimal placement of_phasor_measurement_units_using_gravitat
Optimal placement of_phasor_measurement_units_using_gravitat
 
Optimal PMU Placement in Power System Considering the Measurement Redundancy
Optimal PMU Placement in Power System Considering the Measurement RedundancyOptimal PMU Placement in Power System Considering the Measurement Redundancy
Optimal PMU Placement in Power System Considering the Measurement Redundancy
 
Genetic Algorithm for Solving the Economic Load Dispatch
Genetic Algorithm for Solving the Economic Load DispatchGenetic Algorithm for Solving the Economic Load Dispatch
Genetic Algorithm for Solving the Economic Load Dispatch
 
PAC 1 - Models de negoci a Internet
PAC 1 - Models de negoci a InternetPAC 1 - Models de negoci a Internet
PAC 1 - Models de negoci a Internet
 
Link building
Link buildingLink building
Link building
 
Hybrid Approach to Economic Load Dispatch
Hybrid Approach to Economic Load DispatchHybrid Approach to Economic Load Dispatch
Hybrid Approach to Economic Load Dispatch
 
التسويق الالكتروني في كلمتين
التسويق الالكتروني في كلمتينالتسويق الالكتروني في كلمتين
التسويق الالكتروني في كلمتين
 
Scanor resot
Scanor resotScanor resot
Scanor resot
 
My home town sustainability
My home town sustainabilityMy home town sustainability
My home town sustainability
 
Sustainable urban trans. in hannover
Sustainable urban trans. in hannoverSustainable urban trans. in hannover
Sustainable urban trans. in hannover
 
ζωγραφικη ρευματα
ζωγραφικη ρευματαζωγραφικη ρευματα
ζωγραφικη ρευματα
 
التسويق الالكتروني
التسويق الالكترونيالتسويق الالكتروني
التسويق الالكتروني
 
Voltage Stability Assessment using Phasor Measurement Units in Power Network ...
Voltage Stability Assessment using Phasor Measurement Units in Power Network ...Voltage Stability Assessment using Phasor Measurement Units in Power Network ...
Voltage Stability Assessment using Phasor Measurement Units in Power Network ...
 
Batching and mixing
Batching and mixingBatching and mixing
Batching and mixing
 

Similar a RoR_2_Ruby

Ruby :: Training 1
Ruby :: Training 1Ruby :: Training 1
Ruby :: Training 1
Pavel Tyk
 
Adventures of java developer in ruby world
Adventures of java developer in ruby worldAdventures of java developer in ruby world
Adventures of java developer in ruby world
Orest Ivasiv
 

Similar a RoR_2_Ruby (20)

Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1
 
Ruby :: Training 1
Ruby :: Training 1Ruby :: Training 1
Ruby :: Training 1
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
 
Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010
 
Initiation à Ruby on Rails
Initiation à Ruby on RailsInitiation à Ruby on Rails
Initiation à Ruby on Rails
 
Ruby basics
Ruby basicsRuby basics
Ruby basics
 
Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)
 
Adventures of java developer in ruby world
Adventures of java developer in ruby worldAdventures of java developer in ruby world
Adventures of java developer in ruby world
 
MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?
 
Ruby an overall approach
Ruby an overall approachRuby an overall approach
Ruby an overall approach
 
Why ruby
Why rubyWhy ruby
Why ruby
 
Rails traps
Rails trapsRails traps
Rails traps
 
Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0
 
Ruby Hell Yeah
Ruby Hell YeahRuby Hell Yeah
Ruby Hell Yeah
 
Writing Well-Behaved Unix Utilities
Writing Well-Behaved Unix UtilitiesWriting Well-Behaved Unix Utilities
Writing Well-Behaved Unix Utilities
 
Ruby on Rails : First Mile
Ruby on Rails : First MileRuby on Rails : First Mile
Ruby on Rails : First Mile
 
Cucumber in Practice(en)
Cucumber in Practice(en)Cucumber in Practice(en)
Cucumber in Practice(en)
 
遇見 Ruby on Rails
遇見 Ruby on Rails遇見 Ruby on Rails
遇見 Ruby on Rails
 
Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2
 
Metaprogramming in Ruby
Metaprogramming in RubyMetaprogramming in Ruby
Metaprogramming in Ruby
 

Último

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
ssuserdda66b
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 

Último (20)

Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 

RoR_2_Ruby