class Jaspion::Miya::Object

Represents a single class object

Attributes

children[RW]

Objects can contain other object inside

name[RW]

Object name - Like variable name

type[RW]

Object type - Like variable type

Public Class Methods

available_classes() click to toggle source

Returns all available template classes

# File lib/jaspion/miya/object.rb, line 73
def self.available_classes
  descendants
end
create(class_name, instance_name) click to toggle source

Creates a new instance of the specified Object depending on the plataform's name

@param class_name [String] Object class name @param instance_name [String] Object's instance name

@return [Object] The Object instance depending on the specified

plataform
# 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
new(name = nil) click to toggle source

Initializes an Object object Object's type is defined by the last path of the Ruby class name

@param name [String] Object name

@param import [String] Import value

# File lib/jaspion/miya/object.rb, line 28
def initialize(name = nil)
  @type = self.class.name.split('::').last
  @name = name
  @children = []
end

Public Instance Methods

fetch_child(type) click to toggle source

Look for a Object type inside @objects array

@param type [String] Name of type object to find

@return [Object] If has object, returns it else returns nil

# File lib/jaspion/miya/object.rb, line 46
def fetch_child(type)
  children.find { |c| c.type.eql?(type) }
end
push_child(object) click to toggle source

Pushes an new Object object

@param name [Object] Object object

# File lib/jaspion/miya/object.rb, line 37
def push_child(object)
  children.push(object)
end
templates() click to toggle source

Generate an array of Template objects

@return [Array] List of the Template object that belongs to this class

# File lib/jaspion/miya/object.rb, line 53
def templates
  [Miya::Template.new(self, nil)]
end