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.

kind_of? Returns true if class is the class of obj, or if class is one of the superclasses of obj or modules included in obj.
instance_of?

#Ruby# Introspect (1)相关推荐

  1. #Ruby# Introspect (2)

    3. Looking at Classes superclass => get the parent of any particular class ancestors => get bo ...

  2. Ruby元编程技术(Ruby Metaprogramming techniques)

    我最近考虑了很多元编程(Metaprogramming)的问题,并希望看到更多这方面技术的例子和讲解.无论好坏,元编程已经进入Ruby社区,并成为完成各种任务和简化代码的标准方式.既然找不到这类资源, ...

  3. Ruby: Ruby脚本在测试中的使用

    如果存在以下的场景: 1. 放置在公司的读报机服务器,每天都是开启的: 2. 读报机每天下载报纸,一旦成功/失败,就会有相应的记录生成在某个xml文件中: 3. 现在有过去一年的读报机下载xml,大约 ...

  4. Ruby 之 Block, Proc, Lambda 联系--区别,转载

    Ruby 之 Block, Proc, Lambda Block Block 不是对象,是Ruby的语言特性,近似于闭包(Closure). 范例: def meth    res=  yield   ...

  5. Ubuntu14.04 LTS中安装Ruby 2.4源码操作步骤

    (1).查看是否已安装ruby,执行命令,如下图,可见机子上还没有安装ruby,即使通过apt-get install命令安装也只能安装1.8版本: (2).从  http://www.ruby-la ...

  6. Windows Ruby使用Mysql环境配置

    windows下Ruby使用mysql时候报错: Incorrect MySQL client library version! This gem was compile d for 6.0.0 bu ...

  7. [翻译] Ruby Golf

    原文地址:http://rubysource.com/ruby-golf/ Ruby golf is the art of writing code that uses as few characte ...

  8. Ruby DSL介绍及其在测试数据构造中的使用(2)

    在(1)中介绍了DSL和普通的函数定义之间的区别.在(1)的最后提到,DSL分为内部DSL和外部DSL,我们再看一遍他们的定义:1. External DSLs 用不同于host语言的语言来编写,通过 ...

  9. Ruby DSL介绍及其在测试数据构造中的使用(1)

    什么是DSL?英文全称Domain Specific Language,中文解释为领域专用语言.顾名思义,DSL是针对某个特定领域而开发的语言.像我们平时接触到的C/C++,Java,Python/R ...

最新文章

  1. 2021下午茶数字经济蓝皮书
  2. 总结一下矩阵的基本操作
  3. c++ 正态分布如何根据x求y_knn实战:如何对手写数字进行识别?
  4. 音视频基础概念与流程
  5. 实战总结的7个C程序,好东西不私藏
  6. c# 如何调用java的wsdl文件,C#客户端如何调用wsdl文件
  7. 2019IDEA破解安装
  8. Email 邮件方式激活注册账号
  9. ERROR: No matching distribution found for cv2解决方案
  10. 椭圆方程 matlab,五点差分法(matlab)解椭圆型偏微分方程
  11. P3456 [POI2007]GRZ-Ridges and Valleys
  12. 【Java程序设计】GUI的JTable的一些应用
  13. 新浪微博一键分享手机版JS代码
  14. 这可能是你见过最硬核的微服务入门指南!
  15. Android GC日志
  16. 讲座“计算机与手机导购”
  17. 新生--七年就是一辈子
  18. 手写MySQL常用语法
  19. 【Linux】linux常用基本命令
  20. GeSciLiVis | 想知道你感兴趣的基因有多少人在研究吗!?用这个包来解决吧!!!~

热门文章

  1. 深度学习--TensorFlow(5)BP神经网络(混淆矩阵、准确率、精确率、召回率、F值)
  2. 【全网最精简写法】ES6获取浏览器url跟参
  3. IDEA设置单击左侧项目文件,自动在右侧编辑器打开
  4. Ubuntu 14.04 64位安装深度音乐和深度影音
  5. windows 10 下部署WCF 一些细节
  6. sql 存储过程和函数
  7. 序列化模块--json模块--pickle模块-shelve模块
  8. github后端开发面试题大集合(一)
  9. Python文件打包成exe
  10. wpf浏览器应用程序发布后获取当前应用地址