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
Metaprogramming Ruby
Search
Francisco Fernández Castaño
February 15, 2013
Programming
1
88
Metaprogramming Ruby
A short introduction to dynamic aspects of Ruby and Ruby Object model.
Francisco Fernández Castaño
February 15, 2013
Tweet
Share
More Decks by Francisco Fernández Castaño
See All by Francisco Fernández Castaño
Graph Databases, a little connected tour (Codemotion Rome)
fcofdez
0
140
Bases de datos de grafos, un recorrido conectado
fcofdez
0
87
Graph Databases
fcofdez
1
230
Graph Databases
fcofdez
3
300
Other Decks in Programming
See All in Programming
AIによるイベントストーミング図からのコード生成 / AI-powered code generation from Event Storming diagrams
nrslib
2
1.9k
AI時代のキャリアプラン「技術の引力」からの脱出と「問い」へのいざない / tech-gravity
minodriven
22
7.4k
ぼくの開発環境2026
yuzneri
0
250
Vibe Coding - AI 驅動的軟體開發
mickyp100
0
180
疑似コードによるプロンプト記述、どのくらい正確に実行される?
kokuyouwind
0
390
開発者から情シスまで - 多様なユーザー層に届けるAPI提供戦略 / Postman API Night Okinawa 2026 Winter
tasshi
0
210
NetBSD+Raspberry Piで 本物のPSGを鳴らすデモを OSC駆動の7日間で作った話 / OSC2026Osaka
tsutsui
1
100
20260127_試行錯誤の結晶を1冊に。著者が解説 先輩データサイエンティストからの指南書 / author's_commentary_ds_instructions_guide
nash_efp
1
1k
フロントエンド開発の勘所 -複数事業を経験して見えた判断軸の違い-
heimusu
7
2.8k
今こそ知るべき耐量子計算機暗号(PQC)入門 / PQC: What You Need to Know Now
mackey0225
3
390
なぜSQLはAIぽく見えるのか/why does SQL look AI like
florets1
0
480
24時間止められないシステムを守る-医療ITにおけるランサムウェア対策の実際
koukimiura
1
130
Featured
See All Featured
Making Projects Easy
brettharned
120
6.6k
Automating Front-end Workflow
addyosmani
1371
200k
SEO for Brand Visibility & Recognition
aleyda
0
4.2k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.7k
GitHub's CSS Performance
jonrohan
1032
470k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
340
We Are The Robots
honzajavorek
0
170
The Cult of Friendly URLs
andyhume
79
6.8k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
150
Utilizing Notion as your number one productivity tool
mfonobong
3
220
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
590
Crafting Experiences
bethany
1
56
Transcript
None
Ruby • Orientado a objetos • Lenguaje dinámico • Partes
funcionales (Bloques)
Ruby es simple en apariencia, pero complejo por dentro, como
el cuerpo humano. tratando de hacer que Ruby sea natural, no simple. Yukihiro Matsumoto 'matz'
¿Pero qué es eso del “metaprogramming”?
¿Pero qué es eso del metaprogramming? Metaprogramming is the writing
of computer programs that write or manipulate other programs (or themselves) as their data. Wikipedia
None
¿Pero qué es eso del metaprogramming? • Manejo de mensajes
cuyo destino no es conocido • Capacidad de creación y modificación de clases en runtime
None
Debemos conocer el modelo de objetos de Ruby
Debemos conocer el modelo de objetos de Ruby
en ruby todo es un objeto 2.0.0-rc2 :001 > 1.class
=> Fixnum
en ruby todo se ejecuta dentro de un objeto 2.0.0-rc2
:002 > self => main 2.0.0-rc2 :003 > class MyClass 2.0.0-rc2 :004?> self 2.0.0-rc2 :005?> end => MyClass 2.0.0-rc2 :006 > self => main 2.0.0-rc2 :007 > class MyClass 2.0.0-rc2 :008?> def test 2.0.0-rc2 :009?> self 2.0.0-rc2 :010?> end 2.0.0-rc2 :011?> def self.class_method 2.0.0-rc2 :012?> self 2.0.0-rc2 :013?> end 2.0.0-rc2 :014?> end => nil 2.0.0-rc2 :015 > MyClass.new.test => #<MyClass:0x00000002397860> 2.0.0-rc2 :016 > MyClass.class_method => MyClass
MonkeyPatches 2.0.0-rc2 :017 > class String 2.0.0-rc2 :018?> def replace
2.0.0-rc2 :019?> "dont replace" 2.0.0-rc2 :020?> end 2.0.0-rc2 :021?> end => nil 2.0.0-rc2 :022 > "stast".replace => "dont replace"
Modelo de objetos de Ruby • La keyword class solo
cambia de contexto • Las clases también son objetos de la clase Class
Modelo de objetos de Ruby class MyClass def my_method() @var
= 1 end end Obj1 = MyClass.new Obj1.my_method
Modelo de objetos de Ruby
Jerarquía de Clases class Book include Printable include Document Ancestors
# => [Book, Document, Printable, Object, Kernel, BasicObject] end
Method Lookup
None
None
Conclusiones
Cosas que me he dejado fuera
Preguntas
None