Class: Jaspion::Miya::Object
- Inherits:
-
Object
- Object
- Jaspion::Miya::Object
- Includes:
- Class
- Defined in:
- lib/jaspion/miya/object.rb
Overview
Represents a single class object
Direct Known Subclasses
Instance Attribute Summary collapse
-
#children ⇒ Object
Objects can contain other object inside.
-
#name ⇒ Object
Object name - Like variable name.
-
#type ⇒ Object
Object type - Like variable type.
Class Method Summary collapse
-
.available_classes ⇒ Object
Returns all available template classes.
-
.create(class_name, instance_name) ⇒ Object
Creates a new instance of the specified Object depending on the plataform’s name.
Instance Method Summary collapse
-
#fetch_child(type) ⇒ Object
Look for a Object type inside @objects array.
-
#initialize(name) ⇒ Object
constructor
Initializes an Object object Object’s type is defined by the last path of the Ruby class name.
-
#push_child(object) ⇒ Object
Pushes an new Object object.
-
#templates ⇒ Array
Generate an array of Template objects.
Methods included from Class
#class_methods, #class_variables, #imports, #instance_methods, #instance_variables, #ui?
Constructor Details
#initialize(name) ⇒ Object
Initializes an Object object Object’s type is defined by the last path of the Ruby class name
28 29 30 31 32 |
# File 'lib/jaspion/miya/object.rb', line 28 def initialize(name) @type = self.class.name.split('::').last @name = name @children = [] end |
Instance Attribute Details
#children ⇒ Object
Objects can contain other object inside
20 21 22 |
# File 'lib/jaspion/miya/object.rb', line 20 def children @children end |
#name ⇒ Object
Object name - Like variable name
14 15 16 |
# File 'lib/jaspion/miya/object.rb', line 14 def name @name end |
#type ⇒ Object
Object type - Like variable type
17 18 19 |
# File 'lib/jaspion/miya/object.rb', line 17 def type @type end |
Class Method Details
.available_classes ⇒ Object
Returns all available template classes
73 74 75 |
# File 'lib/jaspion/miya/object.rb', line 73 def self.available_classes descendants end |
.create(class_name, instance_name) ⇒ Object
Creates a new instance of the specified Object depending on the plataform’s name
65 66 67 68 69 70 |
# File 'lib/jaspion/miya/object.rb', line 65 def self.create(class_name, instance_name) return nil unless const_defined?(class_name) clazz = const_get(class_name) clazz.new(instance_name) end |
Instance Method Details
#fetch_child(type) ⇒ Object
Look for a Object type inside @objects array
46 47 48 |
# File 'lib/jaspion/miya/object.rb', line 46 def fetch_child(type) children.find { |c| c.type.eql?(type) } end |
#push_child(object) ⇒ Object
Pushes an new Object object
37 38 39 |
# File 'lib/jaspion/miya/object.rb', line 37 def push_child(object) children.push(object) end |