#Ruby# Introspect (1)
Introspect,内省,是指从程序自身出发,审视程序各方面的能力。这个过程又称为Reflection,反射。
孔子曰,吾日三省吾身。于人于程序,内省都是非常重要的。
1. Looking at objects
ObjectSpace.each_object([module]) {|obj| ... } -> fixnum
ObjectSpace.each_object([module]) -> an_enumerator
ObjectSpace::each_object :
Calls the block once for each living, nonimmediate object in this Ruby process.(Immediate objects (Fixnums, Symbols true,false, and nil) are never returned. )
If module is specified, calls the block for only those classes or modules that match (or are a subclass of) module. Returns the number of objects found.
2. Looking inside objects
methods
respond_to?(symbol, include_private=false) Private methods are included in the search only if the optional second parameter evaluates to true.
#Ruby# Introspect (1)相关推荐
- #Ruby# Introspect (2)
3. Looking at Classes superclass => get the parent of any particular class ancestors => get bo ...
- Ruby元编程技术(Ruby Metaprogramming techniques)
我最近考虑了很多元编程(Metaprogramming)的问题,并希望看到更多这方面技术的例子和讲解.无论好坏,元编程已经进入Ruby社区,并成为完成各种任务和简化代码的标准方式.既然找不到这类资源, ...
- Ruby: Ruby脚本在测试中的使用
如果存在以下的场景: 1. 放置在公司的读报机服务器,每天都是开启的: 2. 读报机每天下载报纸,一旦成功/失败,就会有相应的记录生成在某个xml文件中: 3. 现在有过去一年的读报机下载xml,大约 ...
- Ruby 之 Block, Proc, Lambda 联系--区别,转载
Ruby 之 Block, Proc, Lambda Block Block 不是对象,是Ruby的语言特性,近似于闭包(Closure). 范例: def meth res= yield ...
- Ubuntu14.04 LTS中安装Ruby 2.4源码操作步骤
(1).查看是否已安装ruby,执行命令,如下图,可见机子上还没有安装ruby,即使通过apt-get install命令安装也只能安装1.8版本: (2).从 http://www.ruby-la ...
- Windows Ruby使用Mysql环境配置
windows下Ruby使用mysql时候报错: Incorrect MySQL client library version! This gem was compile d for 6.0.0 bu ...
- [翻译] Ruby Golf
原文地址:http://rubysource.com/ruby-golf/ Ruby golf is the art of writing code that uses as few characte ...
- Ruby DSL介绍及其在测试数据构造中的使用(2)
在(1)中介绍了DSL和普通的函数定义之间的区别.在(1)的最后提到,DSL分为内部DSL和外部DSL,我们再看一遍他们的定义:1. External DSLs 用不同于host语言的语言来编写,通过 ...
- Ruby DSL介绍及其在测试数据构造中的使用(1)
什么是DSL?英文全称Domain Specific Language,中文解释为领域专用语言.顾名思义,DSL是针对某个特定领域而开发的语言.像我们平时接触到的C/C++,Java,Python/R ...
最新文章
- 2021下午茶数字经济蓝皮书
- 总结一下矩阵的基本操作
- c++ 正态分布如何根据x求y_knn实战:如何对手写数字进行识别?
- 音视频基础概念与流程
- 实战总结的7个C程序,好东西不私藏
- c# 如何调用java的wsdl文件,C#客户端如何调用wsdl文件
- 2019IDEA破解安装
- Email 邮件方式激活注册账号
- ERROR: No matching distribution found for cv2解决方案
- 椭圆方程 matlab,五点差分法(matlab)解椭圆型偏微分方程
- P3456 [POI2007]GRZ-Ridges and Valleys
- 【Java程序设计】GUI的JTable的一些应用
- 新浪微博一键分享手机版JS代码
- 这可能是你见过最硬核的微服务入门指南!
- Android GC日志
- 讲座“计算机与手机导购”
- 新生--七年就是一辈子
- 手写MySQL常用语法
- 【Linux】linux常用基本命令
- GeSciLiVis | 想知道你感兴趣的基因有多少人在研究吗!?用这个包来解决吧!!!~