Submit Search
Upload
Ruby Class, Module, Self and Instance_eval Guide
•
0 likes
•
157 views
AI-enhanced title
Jumpei Yokota
Follow
メタプログラミング Ruby の輪読会 4 章までの復習と 5.1〜5.3 章の紹介。
Read less
Read more
Technology
Slideshow view
Report
Share
Slideshow view
Report
Share
1 of 17
Download now
Download to read offline
Recommended
Effective PHP. Part 2
Effective PHP. Part 2
Vasily Kartashov
Effective PHP. Part 4
Effective PHP. Part 4
Vasily Kartashov
Effective PHP. Part 1
Effective PHP. Part 1
Vasily Kartashov
Effective PHP. Part 5
Effective PHP. Part 5
Vasily Kartashov
Effective PHP. Part 3
Effective PHP. Part 3
Vasily Kartashov
Effective PHP. Part 6
Effective PHP. Part 6
Vasily Kartashov
Os Welton
Os Welton
oscon2007
Write codeforhumans
Write codeforhumans
Narendran R
Recommended
Effective PHP. Part 2
Effective PHP. Part 2
Vasily Kartashov
Effective PHP. Part 4
Effective PHP. Part 4
Vasily Kartashov
Effective PHP. Part 1
Effective PHP. Part 1
Vasily Kartashov
Effective PHP. Part 5
Effective PHP. Part 5
Vasily Kartashov
Effective PHP. Part 3
Effective PHP. Part 3
Vasily Kartashov
Effective PHP. Part 6
Effective PHP. Part 6
Vasily Kartashov
Os Welton
Os Welton
oscon2007
Write codeforhumans
Write codeforhumans
Narendran R
Clean Code Principles
Clean Code Principles
YeurDreamin'
Clean code
Clean code
Knoldus Inc.
Dev Concepts: Functional Programming
Dev Concepts: Functional Programming
Svetlin Nakov
Some basic FP concepts
Some basic FP concepts
Falko Riemenschneider
Test in action week 4
Test in action week 4
Yi-Huan Chan
PhpSpec: practical introduction
PhpSpec: practical introduction
Dave Hulbert
Functions in php
Functions in php
Mudasir Syed
Test in action week 3
Test in action week 3
Yi-Huan Chan
php 2 Function creating, calling,PHP built-in function
php 2 Function creating, calling,PHP built-in function
tumetr1
Object Oriented PHP - PART-2
Object Oriented PHP - PART-2
Jalpesh Vasa
Introduction to Python decorators
Introduction to Python decorators
rikbyte
Functions in php
Functions in php
AbdulAzizSapra
Basic constructs i
Basic constructs i
Manjitsing Valvi
Test in action week 2
Test in action week 2
Yi-Huan Chan
Functional programing in Javascript (lite intro)
Functional programing in Javascript (lite intro)
Nikos Kalogridis
Arrays & functions in php
Arrays & functions in php
Ashish Chamoli
PHP Barcelona 2010 - Architecture and testability
PHP Barcelona 2010 - Architecture and testability
Giorgio Sironi
Java 8 by example!
Java 8 by example!
Mark Harrison
Functional programming
Functional programming
Kibru Demeke
Code generating beans in Java
Code generating beans in Java
Stephen Colebourne
Preparing for the next PHP version (5.6)
Preparing for the next PHP version (5.6)
Damien Seguy
Perl Teach-In (part 2)
Perl Teach-In (part 2)
Dave Cross
More Related Content
What's hot
Clean Code Principles
Clean Code Principles
YeurDreamin'
Clean code
Clean code
Knoldus Inc.
Dev Concepts: Functional Programming
Dev Concepts: Functional Programming
Svetlin Nakov
Some basic FP concepts
Some basic FP concepts
Falko Riemenschneider
Test in action week 4
Test in action week 4
Yi-Huan Chan
PhpSpec: practical introduction
PhpSpec: practical introduction
Dave Hulbert
Functions in php
Functions in php
Mudasir Syed
Test in action week 3
Test in action week 3
Yi-Huan Chan
php 2 Function creating, calling,PHP built-in function
php 2 Function creating, calling,PHP built-in function
tumetr1
Object Oriented PHP - PART-2
Object Oriented PHP - PART-2
Jalpesh Vasa
Introduction to Python decorators
Introduction to Python decorators
rikbyte
Functions in php
Functions in php
AbdulAzizSapra
Basic constructs i
Basic constructs i
Manjitsing Valvi
Test in action week 2
Test in action week 2
Yi-Huan Chan
Functional programing in Javascript (lite intro)
Functional programing in Javascript (lite intro)
Nikos Kalogridis
Arrays & functions in php
Arrays & functions in php
Ashish Chamoli
PHP Barcelona 2010 - Architecture and testability
PHP Barcelona 2010 - Architecture and testability
Giorgio Sironi
Java 8 by example!
Java 8 by example!
Mark Harrison
Functional programming
Functional programming
Kibru Demeke
Code generating beans in Java
Code generating beans in Java
Stephen Colebourne
What's hot
(20)
Clean Code Principles
Clean Code Principles
Clean code
Clean code
Dev Concepts: Functional Programming
Dev Concepts: Functional Programming
Some basic FP concepts
Some basic FP concepts
Test in action week 4
Test in action week 4
PhpSpec: practical introduction
PhpSpec: practical introduction
Functions in php
Functions in php
Test in action week 3
Test in action week 3
php 2 Function creating, calling,PHP built-in function
php 2 Function creating, calling,PHP built-in function
Object Oriented PHP - PART-2
Object Oriented PHP - PART-2
Introduction to Python decorators
Introduction to Python decorators
Functions in php
Functions in php
Basic constructs i
Basic constructs i
Test in action week 2
Test in action week 2
Functional programing in Javascript (lite intro)
Functional programing in Javascript (lite intro)
Arrays & functions in php
Arrays & functions in php
PHP Barcelona 2010 - Architecture and testability
PHP Barcelona 2010 - Architecture and testability
Java 8 by example!
Java 8 by example!
Functional programming
Functional programming
Code generating beans in Java
Code generating beans in Java
Similar to Ruby Class, Module, Self and Instance_eval Guide
Preparing for the next PHP version (5.6)
Preparing for the next PHP version (5.6)
Damien Seguy
Perl Teach-In (part 2)
Perl Teach-In (part 2)
Dave Cross
Damien seguy php 5.6
Damien seguy php 5.6
Damien Seguy
Functional Javascript
Functional Javascript
guest4d57e6
Python fundamentals - basic | WeiYuan
Python fundamentals - basic | WeiYuan
Wei-Yuan Chang
PHP 5.3 Overview
PHP 5.3 Overview
jsmith92
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12
Michelangelo van Dam
Lecture9_OOPHP_SPring2023.pptx
Lecture9_OOPHP_SPring2023.pptx
ShaimaaMohamedGalal
Ch8(oop)
Ch8(oop)
Chhom Karath
PHPUnit best practices presentation
PHPUnit best practices presentation
Thanh Robi
Write your Ruby in Style
Write your Ruby in Style
Bhavin Javia
QA for PHP projects
QA for PHP projects
Michelangelo van Dam
Quality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStorm
Michelangelo van Dam
The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5
Wim Godden
The why and how of moving to php 5.4
The why and how of moving to php 5.4
Wim Godden
Python lecture 8
Python lecture 8
Tanwir Zaman
Magic methods
Magic methods
Matthew Barlocker
The why and how of moving to php 5.4/5.5
The why and how of moving to php 5.4/5.5
Wim Godden
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012
Michelangelo van Dam
Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010
Fabien Potencier
Similar to Ruby Class, Module, Self and Instance_eval Guide
(20)
Preparing for the next PHP version (5.6)
Preparing for the next PHP version (5.6)
Perl Teach-In (part 2)
Perl Teach-In (part 2)
Damien seguy php 5.6
Damien seguy php 5.6
Functional Javascript
Functional Javascript
Python fundamentals - basic | WeiYuan
Python fundamentals - basic | WeiYuan
PHP 5.3 Overview
PHP 5.3 Overview
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12
Lecture9_OOPHP_SPring2023.pptx
Lecture9_OOPHP_SPring2023.pptx
Ch8(oop)
Ch8(oop)
PHPUnit best practices presentation
PHPUnit best practices presentation
Write your Ruby in Style
Write your Ruby in Style
QA for PHP projects
QA for PHP projects
Quality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStorm
The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5
The why and how of moving to php 5.4
The why and how of moving to php 5.4
Python lecture 8
Python lecture 8
Magic methods
Magic methods
The why and how of moving to php 5.4/5.5
The why and how of moving to php 5.4/5.5
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012
Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010
Recently uploaded
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
Ridwan Fadjar
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
comworks
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
Fwdays
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Safe Software
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
Fwdays
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
Slibray Presentation
Training state-of-the-art general text embedding
Training state-of-the-art general text embedding
Zilliz
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
SeasiaInfotech2
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Zilliz
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
Commit University
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Wonjun Hwang
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
Scott Keck-Warren
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
Manik S Magar
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
carlostorres15106
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
Fwdays
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
UiPathCommunity
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
Rizwan Syed
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
Fwdays
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
Alex Barbosa Coqueiro
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
gvaughan
Recently uploaded
(20)
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
Training state-of-the-art general text embedding
Training state-of-the-art general text embedding
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
Ruby Class, Module, Self and Instance_eval Guide
1.
RUBY § 1-4 ,
§ 5.1-5.3 Jumpei Yokota @IPROS Corp. 1
2.
§ 1-4 2
3.
➤ ➤ obj.class #
=> Greetin ➤ ➤ obj.class.instance_methods(false) # => [:welcome] ➤ ➤ obj.instance_variables # => [:@text] 3
4.
➤ include ➤ ➤ ➤ Ruby
4
5.
➤ Refinements ➤ module
StringExtentions; refine String do; def … ➤ ➤ Object#send obj.send(my_method, 3) ➤ Module#define_method ➤ method_missing ➤ class String; def method_missing(method, *args)… 5
6.
➤ ➤ my_method {|x|
“x + y”} ➤ Kernel#block_given? ➤ ➤ 6
7.
instance_eval ➤ ➤ BasicObject#instance_eval ➤ → 7
8.
➤ Proc ➤ ➤ & ➤
lambda ➤ return lambda Proc Proc ➤ ➤ ➤ Object#method ➤ Object#call ➤ Method#to_proc ⇔ Module#define_method 8
9.
§ 5 9
10.
➤ Ruby → self ➤
self ➤ self self main Object 10
11.
obj D → D C 11
12.
CLASS_EVAL ➤ Module#class_eval 12
13.
self obj obj 2 MyClass 13
14.
CLASS_EVAL ➤ ➤ Loan to_s
def to_s # initialize @time = Time.now “#{@book.upcase} loaned on #{@time}” end ➤ ➤ @time = Loan.time_class.now ➤ def self.time_class @time_class || Time # @time_class = nil → end ➤ @time_class FakeTime Loan.instance_eval { @time_class = FakeTime } 14
15.
➤ ➤ String str
title? ➤ Object#define_singleton_method 15
16.
➤ self.hoge 16
17.
➤ Ruby ➤ ➤ Module#attr_ ➤
Module#attr_reader ➤ Module#attr_writer ➤ Module#attr_accessor 17
Download now