惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
博客园_首页
博客园 - 三生石上(FineUI控件)
V
Visual Studio Blog
Hugging Face - Blog
Hugging Face - Blog
美团技术团队
小众软件
小众软件
T
Tailwind CSS Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
月光博客
月光博客
有赞技术团队
有赞技术团队
WordPress大学
WordPress大学
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
罗磊的独立博客
V
V2EX
酷 壳 – CoolShell
酷 壳 – CoolShell
IT之家
IT之家
量子位
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Recent Announcements
Recent Announcements
M
MIT News - Artificial intelligence
阮一峰的网络日志
阮一峰的网络日志
The GitHub Blog
The GitHub Blog

博客园 - 阿飞外传

简单rails开发环境 关于MDA的长期等待 Is MOF the kernel language of MDA langs family graduated 语言内实例表示机制 类型信息隐藏 MOF自描述 图模式-续 符号软件工程(SSE) next MDA? Algebra operator declaration 's UML profile 应用元建模读书笔记 再谈实例化和图转换 EclipseUML2.0::Class的接口 主题与模型 MDA轮廓 UML::Element的代数规范 UML::InstanceValue是元类吗 MDA is a big reflection i need a job CGN的IP之父访谈的两句话 A sample of writing a loop in Action Semantic codes
ruby-core
阿飞外传 · 2006-09-21 · via 博客园 - 阿飞外传

包中的是ruby的核心类(算是M2+M3级)
外面的User是M1级。 虚线是instance_of关系
具有金穗带构架,Object.instance_of?(Class) = true, Class.ancestors.include?(Object) = true

不是很明白,中间杀出个程咬金:Module

总体原则是,核心类簇中继承链中的叶类作为实例化关系的祖先, 即Class

一些特征:
1)特定于某对象的方法(单例类实例的方法)
  str = "sdfsdf"
  def str.foo
    puts "a per object method"
  end

2)DSL特征,在Module类中增加方法,以便用户类在定义时调用。

class Module
  @@doc = {}
  def doc(str)
    @@doc[self.name] = str
  end
  def Moduel.doc(aClass)
    aClass = aClass.name if aClass.class <= Module
    @@doc[aClass]
  end
end

class User
  doc "here is the doc for user"
end
 
3)条件定义

def foo
  if $DEBUG
    def foo
      puts "debug version"
    end
   else
  end
end 

4)匿名类

class User
   @class_val = 123
   class <<self
     def aClassMethod
       puts @class_val
     end
   end
end