Class: Lipa::Root
Overview
Implementaion of root of description
Constant Summary collapse
- @@trees =
{}
Instance Attribute Summary collapse
-
#kinds ⇒ Object
readonly
Returns the value of attribute kinds.
Attributes inherited from Node
#attrs, #children, #full_name, #name, #parent, #root
Class Method Summary collapse
-
.[](uri) ⇒ Node
Accessor for node by uri.
Instance Method Summary collapse
-
#initialize(name, &block) ⇒ Root
constructor
A new instance of Root.
-
#kind(name, attrs = {}, &block) ⇒ Object
(also: #template)
Initialize of kind.
-
#load_from(path) ⇒ Object
Load description tree from file.
Methods inherited from Node
#[], add_node, #eval_attrs, init_methods, #method_missing, #ref, #run, #with
Constructor Details
#initialize(name, &block) ⇒ Root
Returns a new instance of Root.
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/lipa/root.rb', line 42 def initialize(name, &block) @kinds = {} @root = self @children = {} @attrs = {} @name = "/" @full_name = "/" instance_eval &block if block_given? @@trees.merge! name.to_s => self end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Lipa::Node
Instance Attribute Details
#kinds ⇒ Object (readonly)
Returns the value of attribute kinds.
40 41 42 |
# File 'lib/lipa/root.rb', line 40 def kinds @kinds end |
Class Method Details
.[](uri) ⇒ Node
Accessor for node by uri
77 78 79 80 |
# File 'lib/lipa/root.rb', line 77 def self.[](uri) tree, path = uri.split("://") @@trees[tree][path] if @@trees[tree] end |
Instance Method Details
#kind(name, attrs = {}, &block) ⇒ Object Also known as: template
Initialize of kind
64 65 66 |
# File 'lib/lipa/root.rb', line 64 def kind(name, attrs = {}, &block) @kinds[name.to_sym] = Lipa::Kind.new(name, attrs, &block) end |
#load_from(path) ⇒ Object
Load description tree from file
90 91 92 93 94 |
# File 'lib/lipa/root.rb', line 90 def load_from(path) File.open(path,'r') do |f| instance_eval f.read end end |