Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Introducción a Ruby
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Victor Camacho
October 22, 2014
Programming
34
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introducción a Ruby
Victor Camacho
October 22, 2014
Other Decks in Programming
See All in Programming
Next.js: The final boss of Web Performance
guaca
0
260
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
220
最近”作らせてる” ローカルAIアプリの話
akit37
0
470
外から家のPCの電源入れたい!をPHPで解決する
kawashimo0
1
140
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
2
940
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
590
golang-bob.pdf
iwatsukayura
0
130
すこし踏み込む CancellationToken
htkym
2
1.7k
なぜCTOを降りてFDEを選んだのか?〜なぜプロダクト企業がFDEで顧客の現場に踏み込むのか〜
gonta
1
210
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
5.2k
AIで開発が速くなった先で、開発チームは何を目指すか
shihochan
0
1.5k
3回つくってわかった、 定期実行ジョブ基盤の本質情報
takai
0
500
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
2
950
How Software Deployment tools have changed in the past 20 years
geshan
2
35k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.6k
Why Our Code Smells
bkeepers
PRO
340
58k
The Pragmatic Product Professional
lauravandoore
37
7.5k
Rails Girls Zürich Keynote
gr2m
96
14k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
410
Building Better People: How to give real-time feedback that sticks.
wjessup
371
20k
We Have a Design System, Now What?
morganepeng
55
8.4k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
590
Transcript
Introducción a Ruby
Instalación
$ ruby -v ruby 2.0.0p0 (2013-02-24 revision 39474 [x86_64-darwin12.2.0]
Mac OS X y Linux ❤️
http://rvm.io/ Ruby Version Manager (RVM) http://rbenv.org rbenv
Windows
http://rubyinstaller.org/ Ruby Installer Una versión de Ruby https://github.com/vertiginous/pik Pik Multiples
Rubies
Ruby es un lenguaje de programación orientado a objetos desarrollado
por Yukihiro “Matz” Matsumoto
Todo es un objeto
5.times { print "OMGWTFBBQ!" }
EJEMPLOS about_objects.rb https://github.com/vicocamacho/koans.git
Strings
Son secuencias de caracteres entre comillas simples o dobles.
Comillas Simples puts ’Hola Mundo!’ => Hola Mundo!
Comillas Dobles puts ”Hola\n#{‘MUNDO’.downcase}!” => Hola mundo
Usando % y << puts ”Hola\n#{‘MUNDO’.downcase}!” => Hola mundo puts
%{Hola Mundo} => Hola Mundo puts <<EOS Hola Mundo EOS => Hola Mundo
EJEMPLOS about_strings.rb https://github.com/vicocamacho/koans.git
Arrays
Un arreglo es una colección de objetos indexados por un
entero no negativo.
array_one = Array.new array_two = []
array_three = ["a", "b", "c"] array_four = %w[a b c]
puts array_three[2] => “c” puts array_three[1, 2] => [“b”, “c”]
puts array_three[0..2] => [“a”, “b”, “c”] puts array_three[-1] => “c”
EJEMPLOS about_arrays.rb https://github.com/vicocamacho/koans.git
Hashes
Hashes son parecidos a los arreglos, con la excepción de
que un hash no solamente contiene valores si no también llaves que apuntan a esos valores.
hash_one = Hash.new hash_two = {}
hash_three = {"a" => 1, "b" => 2}
Generalmente se utilizan símbolos como llaves debido a que es
más rápido el acceso.
hash_four = { :a => 1, :b => 2 }
hash_four = { a: 1, b: 2 } Ruby >= 1.9 Ruby < 1.9
EJEMPLOS about_hashes.rb https://github.com/vicocamacho/koans.git
Símbolos
Los símbolos son nombres constantes que no tenemos que predeclarar
y que esta garantizado sean únicos.
walk(:north) hash = { a: 1, b: 2 } hash[:a]
Estructuras de control
today = Time.now if today.saturday? puts "Do something" elsif today.sunday?
puts “Relax" else puts "Go to work" end If / else y unless
today = Time.now if today.saturday? puts "Do something" elsif today.sunday?
puts “Relax" else puts "Go to work" end If / else y unless => ”Go to work”
while line = gets puts line.downcase end While / Untill
while line = gets puts line.downcase end While / Untill
”HOLA” => “hola”
if radiation > 300 puts “Peligro” end Modificadores de declaración
puts “Peligro” if radiation > 300 Modificadores de declaración
puts “Algo” while doing_something Modificadores de declaración
for number in [“uno”, “dos”] puts number end For
for number in [“uno”, “dos”] puts number end For =>
“uno” => “dos”
EJEMPLOS about_control_statements.rb https://github.com/vicocamacho/koans.git
Bloques
Los bloques son pedazos de código que podemos asociar con
llamadas a métodos, casi como si fueran parámetros.
do puts “Hello” end { puts “Hello” }
def call_block puts "Start Method" yield yield puts "End Method"
end call_block { puts "In the block" }
def call_block puts "Start Method" yield yield puts "End Method"
end call_block { puts "In the block" } => “Start Method” => “In the block” => “In the block” => “End method”
def who_says_what yield(“Dave”, “hello”) yield(“Andy”,“goodbye”) end who_says_what do |who, what|
puts “#{who} says #{what}“ end
def who_says_what yield(“Dave”, “hello”) yield(“Andy”,“goodbye”) end who_says_what do |who, what|
puts “#{who} says #{what}“ end => “Dave says hello” => “Andy says goodbye”
EJEMPLOS about_blocks.rb https://github.com/vicocamacho/koans.git
Iteradores
Los iteradores son métodos que regresan una serie sucesiva de
elementos en una colección
animals = %w(cat dog bee ant) animals.each do |animal| puts
animal end
animals = %w(cat dog bee ant) animals.each do |animal| puts
animal end => ”Cat” => ”Dog” => ”Bee” => ”Ant”
EJEMPLOS about_iteration.rb https://github.com/vicocamacho/koans.git