Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Ruby
Search
Miguel Michelson Martinez
August 29, 2013
Programming
1
350
Ruby
charla de ruby para continuum tour
Miguel Michelson Martinez
August 29, 2013
Tweet
Share
More Decks by Miguel Michelson Martinez
See All by Miguel Michelson Martinez
Rubymotion
michelson
0
57
Thor
michelson
1
63
Other Decks in Programming
See All in Programming
Amazon RDS 向けに提供されている MCP Server と仕組みを調べてみた/jawsug-okayama-2025-aurora-mcp
takahashiikki
1
110
開発チーム・開発組織の設計改善スキルの向上
masuda220
PRO
20
11k
請來的 AI Agent 同事們在寫程式時,怎麼用 pytest 去除各種幻想與盲點
keitheis
0
120
Deep Dive into Kotlin Flow
jmatsu
1
330
奥深くて厄介な「改行」と仲良くなる20分
oguemon
1
520
🔨 小さなビルドシステムを作る
momeemt
4
680
MCPでVibe Working。そして、結局はContext Eng(略)/ Working with Vibe on MCP And Context Eng
rkaga
5
2.3k
Swift Updates - Learn Languages 2025
koher
2
470
How Android Uses Data Structures Behind The Scenes
l2hyunwoo
0
440
デザイナーが Androidエンジニアに 挑戦してみた
874wokiite
0
360
Cache Me If You Can
ryunen344
2
700
Improving my own Ruby thereafter
sisshiki1969
1
160
Featured
See All Featured
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
126
53k
Done Done
chrislema
185
16k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Speed Design
sergeychernyshev
32
1.1k
RailsConf 2023
tenderlove
30
1.2k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
139
34k
Raft: Consensus for Rubyists
vanstee
140
7.1k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
285
13k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
9
810
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Transcript
CODE IS POETRY Ruby & Friends Monday, September 2, 13
MIGUEL MICHELSON https://github.com/michelson/ https://twitter.com/michelson/ RUBY DEVELOPER @ CONTINUUM Monday, September
2, 13
7 AÑOS PROGRAMANDO EN RUBY/RAILS Monday, September 2, 13
@MICHELSON Monday, September 2, 13
Monday, September 2, 13
RUBY Lenguaje OOP Permite metaprogramar sintaxis muy expresiva facil de
usar y extender Monday, September 2, 13
Yukihiro "Matz" Matsumoto Ruby es creado por Yukihiro "Matz" Matsumoto,
quien comenzó a trabajar en Ruby en 1993, y lo presentó públicamente en 1995. Monday, September 2, 13
PRINCIPIOS Monday, September 2, 13
Monday, September 2, 13
Lenguage enfocado en los humanos , no las máquinas Monday,
September 2, 13
Lenguage enfocado en los humanos , no las máquinas Diseñado
para la productividad y la diversión del desarrollador Monday, September 2, 13
“Nosotros somos los jefes. No las computadoras.” Monday, September 2,
13
Optimized for Happiness Monday, September 2, 13
7.times do puts "don’t repeat yourself" end Monday, September 2,
13
Monday, September 2, 13
IMPLEMENTACIONES Monday, September 2, 13
INTERPRETES MRI - 1.8.7, 1.9.3, 2.0 JRuby Rubinius MacRuby IronRuby
mRuby Monday, September 2, 13
DIFERENTES USOS Web Apps Desktop Apps Command Line Mobile Apps
Embebed system Monday, September 2, 13
RUBY ON RAILS Monday, September 2, 13
WEB APPS Monday, September 2, 13
Sinatra Padrino Camping Ramaze Grape Cuba Monday, September 2, 13
Rack provides a minimal interface between webservers supporting Ruby and
Ruby frameworks. Monday, September 2, 13
DESKTOP/MOBILE APPS Java Swing QT RubyMotion Ruboto Monday, September 2,
13
COMMAND LINE APPS Capistrano RAKE THOR Chef Bundler Monday, September
2, 13
RUBY Reflexivo y OO Monday, September 2, 13
REFLEXIVO Permite examinar su estado y estructura o.class? o.superclass o.instance_of?
o.is_a? o o.kind_of? o.respond_to? Name Monday, September 2, 13
OOP Define tipos de datos Crea operaciones sobre esos tipos
Instancia tipos de datos Monday, September 2, 13
METAPROGRAMACION La metaprogramación consiste en escribir programas que escriben o
manipulan otros programas (o a sí mismos) Ahorran la escritura de código Monday, September 2, 13
Monday, September 2, 13
METAPROGRAMACION User.find_by_id_or_last_name Monday, September 2, 13
ORIENTADO A OBJETOS Monday, September 2, 13
TODO ES UN OBJETO Monday, September 2, 13
PROBEMOS RUBY Monday, September 2, 13
Monday, September 2, 13
Paquetes - Gems • RubyGems • 60M+ gems cut since
July 2009. • rails, sinatra, rvm , nokogiri, etc.. etc.. Monday, September 2, 13
Instalando una gema Monday, September 2, 13
Variables human = "you" Monday, September 2, 13
Tipos de variables local = ... @instancia = .... @@clase
= .... $global = ... CONSTANTE = ... Monday, September 2, 13
Arreglos [] [1, “dos”, nil] [[“a”, 1], [“a”]] Monday, September
2, 13
Diccionarios {} { ‘a’=> 1, ‘b’=> 2} Hash.new Monday, September
2, 13
Sintaxis opcional Monday, September 2, 13
Interpolación de string Monday, September 2, 13
Interpolación de string Monday, September 2, 13
Interpolación de string Monday, September 2, 13
Interpolación de string Monday, September 2, 13
Metodos def my_method #code here .... end Monday, September 2,
13
Metodos Monday, September 2, 13
Monday, September 2, 13
Monday, September 2, 13
Monday, September 2, 13
Monday, September 2, 13
Monday, September 2, 13
Monday, September 2, 13
Monday, September 2, 13
RUBY Monday, September 2, 13
Encadenar metodos Monday, September 2, 13
Encadenar metodos Monday, September 2, 13
Encadenar metodos Monday, September 2, 13
Encadenar metodos Monday, September 2, 13
Condicionales Es como en todos los lenguajes, if, else, case
Pero ... Monday, September 2, 13
Condicionales Uso de unless OneLiner derecha a izq Ejemplo.. Monday,
September 2, 13
Condicionales Monday, September 2, 13
RUBY Monday, September 2, 13
Iteradores ary = [1,2,3,4,5] ary.each do | num | puts
num end result: 1 2 3 4 5 Monday, September 2, 13
Iteradores ary = [1,2,3,4,5] ary.each do | num | puts
num end result: 1 2 3 4 5 Monday, September 2, 13
Iteradores ary = [1,2,3,4,5] ary.each{ | num | puts num
} result: 1 2 3 4 5 Monday, September 2, 13
Iteradores ary = [1,2,3,4,5] ary.each{ | num | puts num
} result: 1 2 3 4 5 Monday, September 2, 13
Iteradores ary = [1,2,3,4,5] ary.each{ | num | puts num
} result: 1 2 3 4 5 Monday, September 2, 13
Iteradores ary = [1,2,3,4,5] ary.each{ | num | puts num
} result: 1 2 3 4 5 Monday, September 2, 13
Iteradores Enumerator Monday, September 2, 13
Iteradores Monday, September 2, 13
Iteradores • each , inject , collect , select ,
map ... Monday, September 2, 13
Iteradores • each , inject , collect , select ,
map ... • {}.each.class #=> Enumerator Monday, September 2, 13
Iteradores • each , inject , collect , select ,
map ... • {}.each.class #=> Enumerator • [].each.class #=> Enumerator Monday, September 2, 13
Select Monday, September 2, 13
Select Monday, September 2, 13
Inject Monday, September 2, 13
Inject Monday, September 2, 13
Collect Monday, September 2, 13
Collect Monday, September 2, 13
Collect Monday, September 2, 13
Collect Monday, September 2, 13
Classes class Persona attr_accessor :nombre, :apellido end Monday, September 2,
13
Classes class Persona attr_accessor :nombre, :apellido end a = Persona.new
a.nombre = “migue” #=>#<Persona:0x00718 @nombre="migue"> Monday, September 2, 13
Getters / Setters • attr_accessor # getter y setter •
attr_reader # getter • attr_writter # setter Monday, September 2, 13
attr_writer :age = Monday, September 2, 13
attr_writer If you write: attr_writer :edad That gets translated into:
def age=(value) @age = value end def age @age end Monday, September 2, 13
attr_reader :age = Monday, September 2, 13
attr_reader If you write: attr_reader :age That gets translated into:
def age @age end Monday, September 2, 13
attr_accessor :age = Monday, September 2, 13
attr_accessor If you write: attr_writer :edad That gets translated into:
def age=(value) @age = value end def age @age end Monday, September 2, 13
Constructores class Person attr_accessor :fname, :lname def initialize(fname, lname) @fname
= fname @lname = lname end end Monday, September 2, 13
Constructores matz = Person.new("Yukihiro", "Matsumoto") Monday, September 2, 13
Herencia class Animal def barf puts “barf barf!” end end
class Human < Animal end Monday, September 2, 13
Herencia class Animal def barf puts “barf barf!” end end
class Human < Animal end Monday, September 2, 13
Modulos / Mixins Monday, September 2, 13
Modulos / Mixins • Ruby no soporta herencia multiple Monday,
September 2, 13
Modulos / Mixins • Ruby no soporta herencia multiple •
Pero soporta mixins Monday, September 2, 13
Modulos module Validator def validate! puts "no actor" if @actor.nil?
end end Monday, September 2, 13
Mixin class Person attr_accessor :actor include Validator end incluye metodos
de instancia Monday, September 2, 13
class Person attr_accessor :actor include Validator end p = Person.new
p.validate! #=> “no actor” Monday, September 2, 13
Metaprogramacion • Permite la generación de metodos en tiempo de
ejecución. • Sirve para escribir código que escribe codigo que escribe código. Monday, September 2, 13
Sin metaprogramación Monday, September 2, 13
Metaprogramación • Con meta programación %w(user email food).each do |meth|
define_method(meth){ @data[meth.to_sym] } end Monday, September 2, 13
Metaprogramación • Con meta programación %w(user email food).each do |meth|
define_method(meth){ @data[meth.to_sym] } end Monday, September 2, 13
Method missing Post.find_by_title("Awesomeness!") User.find_by_email("
[email protected]
") User.find_by_email_and_login("
[email protected]
", "bob") Monday, September 2, 13
Monday, September 2, 13
Method missing class ActiveRecord::Base def method_missing(meth, *args, &block) if meth.to_s
=~ /^find_by_(.+)$/ run_find_by_method($1, *args, &block) else super end end Monday, September 2, 13
Method missing class ActiveRecord::Base def method_missing(meth, *args, &block) if meth.to_s
=~ /^find_by_(.+)$/ run_find_by_method($1, *args, &block) else super end end Monday, September 2, 13
Comunidades • Ror-es google group • Irc ruby #freenode •
http://www.ruby-forum.com/ • http://tryruby.org • railscasts.com • rubyweekly.com • rubyflow.com Monday, September 2, 13
Monday, September 2, 13
•Gracias! Monday, September 2, 13
¿Listo para probar Ruby? http://tryruby.org Monday, September 2, 13