`
Goldice
  • 浏览: 106960 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

#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.

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?



分享到:
评论

相关推荐

    SwiftUI-Introspect:自检SwiftUI的底层UIKit组件

    对SwiftUI的内省 Introspect允许您获取SwiftUI视图的基础UIKit或AppKit元素。 例如,使用Introspect,您可以访问UITableView来修改分隔符,或者访问UINavigationController来自定义选项卡栏。这个怎么运作Introspect...

    ruby-dbus:DBus的Ruby绑定

    Ruby D-Bus 是Linux的进程间通信机制。...upower_object.introspect upower_interface = upower_object["org.freedesktop.UPower"] on_battery = upower_interface["OnBattery"] if on_battery puts "The comput

    Introspect-crx插件

    **如果是这样,Introspect是您的理想扩展!**** Introspect可以做什么? -评估,描述和反思您的日常生活-通过信息丰富的统计信息深入了解您的生活-查看和编辑以前的任何回复-以CSV格式导出数据-使用深色和浅色主题...

    introspect-fun:JavaScript函数自省以检索函数的参数名称

    内省的乐趣 能够对函数进行自省的节点模块,可以在数组中返回其参数名称。 安装 npm install --save introspect-fun 原料药 基本用途 var introspect = require ( '...var res1 = introspect ( noArgs ) ; // res1 =

    introspect.github.io

    introspect.github.io

    dbus-introspect:Bourne Shell脚本反省DBus

    1. **理解服务接口**:确定DBus服务提供了哪些接口,以及它们各自包含的方法和信号。 2. **调试应用通信**:当应用无法正确通信时,可以通过检查DBus接口来定位问题。 3. **学习示例代码**:对于新开发者,可以查看...

    introspect-typed

    var matchType = require ( 'introspect-typed' ) . matchType ; matchType ( String , 'yes!' ) ; // => true matchType ( Number , 'no...' ) ; // => false 获取匹配器功能 var matchType = require ( '...

    NSDictionary-Introspect:Objective-C 运行时属性自省

    是推荐的安装NSDictionary-Introspect 。 只需Podfile添加到您的Podfile : 播客文件 pod 'NSDictionary-Introspect' 用法 要使用此代码,请覆盖 NSObject 的 description 方法,如下所示: - ( NSString *)...

    npm-cache-introspect:内省你的本地 npm 缓存

    请勿使用:正在进行的工作 这是对制作一个将内省 npm 缓存的模块的探索。 它在当前形式下不可用。 想法 给定一组模块名称和版本约束,该模块将内省本地 npm 缓存,以查看本地缓存中是否存在满足它的模块 ...

    introspect-frontend

    1. **前端框架**:项目可能基于流行的前端框架,如React、Vue或Angular。这些框架提供了构建复杂用户界面的结构,并支持组件化开发,使得代码组织更加清晰,易于维护。 2. **模块化与打包工具**:项目可能使用...

    pytest最新文档

    ##### 6.5 固件可以内省请求测试的上下文 (Fixtures can introspect the requesting test context) - 固件可以访问请求它的测试函数的信息,从而实现更灵活的功能。 ##### 6.6 参数化的固件 (Parametrizing ...

    D-BUS实例讲解

    - 分析`_introspect_parser`的输出格式。 #### 五、使用dbus-glib ##### 5.1 接口描述文件 - **创建**: 编写`.xml`文件来描述接口。 - **生成绑定**: 使用`gdbus-codegen`工具自动生成绑定代码。 ##### 5.2 对象...

    GWT in Action

    GWT's powerful generators can introspect code at compile time and generate new subclasses with additional functionality. This chapter teaches readers how to build such generators and use them to ...

    自检SwiftUI的底层UIKit组件-Swift开发

    对SwiftUI的深入了解Introspect允许您获取SwiftUI视图的基础UIKit或AppKit元素。 例如,使用Introspect,您可以访问UITableView来修改分隔符,或者可以使用UINavigationController来定制customiz Introspect for ...

    ist的matlab代码-contrail-introspect-cli:使ContrailIntrospect输出CLI友好的脚本

    ist的matlab代码转换轨迹 该脚本提供了一个Contrail CLI命令,主要用于对目的进行故障排除。 它从Contrail主要组件(例如控件,配置和comptue(vrouter)节点)提供的自省服务中检索XML输出,并使它们与CLI友好。...

    spring-boot-02-config.zip

    1. 配置文件 application.properties application.yml 2. 配置文件的作用:修改SpringBoot自动配置的默认值 3. yml的语法 格式:k:(空格)v 表示一对键值对(空格必须有),大小写敏感 以空格的...

    docker-introspection:Docker 自省 HTTP 服务器

    从容器内,获取容器 id,然后使用curl获取信息: CONTAINER_ID=$(cat /proc/self/cgroup |grep cpu:| sed -r 's#.*docker/(.{12}).*#\1#'­)# For v1.5 # CONTAINER_ID=$(cat /proc/self/cgroup | grep -w cpu | ...

    GraphQL Java

    One very important property of GraphQL is that it is statically typed: the server knows exactly the shape of every object you can query and any client can actually "introspect" the server and ask for...

Global site tag (gtag.js) - Google Analytics