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
Strands Agents で実現する名刺解析アーキテクチャ
omiya0555
1
110
React 使いじゃなくても知っておきたい教養としての React
oukayuka
6
370
バイブコーディング超えてバイブデプロイ〜CloudflareMCPで実現する、未来のアプリケーションデリバリー〜
azukiazusa1
2
720
Jakarta EE Meets AI
ivargrimstad
0
340
PHPカンファレンス関西2025 基調講演
sugimotokei
5
950
AIのメモリー
watany
11
1k
CIを整備してメンテナンスを生成AIに任せる
hazumirr
0
260
Go製CLIツールをnpmで配布するには
syumai
0
520
商品比較サービス「マイベスト」における パーソナライズレコメンドの第一歩
ucchiii43
0
200
CLI ツールを Go ライブラリ として再実装する理由 / Why reimplement a CLI tool as a Go library
ktr_0731
3
430
[DevinMeetupTokyo2025] コード書かせないDevinの使い方
takumiyoshikawa
2
200
React は次の10年を生き残れるか:3つのトレンドから考える
oukayuka
40
15k
Featured
See All Featured
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.8k
Six Lessons from altMBA
skipperchong
28
3.9k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.6k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
2.9k
Java REST API Framework Comparison - PWX 2021
mraible
31
8.7k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
5.9k
Raft: Consensus for Rubyists
vanstee
140
7k
GraphQLとの向き合い方2022年版
quramy
49
14k
Building an army of robots
kneath
306
45k
How GitHub (no longer) Works
holman
314
140k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
33
2.4k
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