Class: CodeNode::IR::Node
- Inherits:
-
Object
- Object
- CodeNode::IR::Node
- Includes:
- BuilderMethods, QueryMethods, TemplateMethods, Cog::Generator
- Defined in:
- lib/code_node/ir/node.rb
Overview
A node in the Graph Nodes come in two flavors: QueryMethods#class? and QueryMethods#module? nodes
Defined Under Namespace
Modules: BuilderMethods, QueryMethods, TemplateMethods
Instance Attribute Summary
Attributes included from TemplateMethods
Attributes included from BuilderMethods
Instance Method Summary collapse
-
#<=>(other) ⇒ FixNum
Order nodes by QueryMethods#path.
-
#initialize(name, opt = {}) ⇒ Node
constructor
Initialize a node.
Methods included from QueryMethods
#class?, #extends?, #includes?, #inherits_from?, #island?, #module?, #path, #singleton?
Methods included from TemplateMethods
#extensions, #inclusions, #key, #label, #stamp_styles, #super_class_node
Methods included from BuilderMethods
#contains, #extends, #find, #includes, #inherits_from, #mark_as_singleton, #prune
Constructor Details
#initialize(name, opt = {}) ⇒ Node
Initialize a node
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/code_node/ir/node.rb', line 224 def initialize(name, opt={}) @style = {} @node_type = opt[:node_type] || :module parent_path = opt[:parent] ? opt[:parent].instance_eval {@path} : [] @path = if name.is_a? Array parent_path + name else parent_path + [name] end @name = @path.last @parent = nil @children = {} @inherits_from = nil @inherited_by = {} @includes = {} @included_by = {} @extends = {} @extended_by = {} end |
Instance Method Details
#<=>(other) ⇒ FixNum
Returns order nodes by CodeNode::IR::Node::QueryMethods#path.
245 246 247 |
# File 'lib/code_node/ir/node.rb', line 245 def <=>(other) path <=> other.path end |