Class: Gloo::Objs::Alias

Inherits:
Core::Obj show all
Defined in:
lib/gloo/objs/basic/alias.rb

Constant Summary collapse

KEYWORD =
'alias'.freeze
KEYWORD_SHORT =
'ln'.freeze
ALIAS_REFERENCE =
'*'.freeze

Constants inherited from Core::Baseo

Core::Baseo::NOT_IMPLEMENTED_ERR

Instance Attribute Summary

Attributes inherited from Core::Obj

#children, #parent, #value

Attributes inherited from Core::Baseo

#name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Core::Obj

#add_child, #add_children_on_create?, #add_default_children, can_create?, #can_receive_message?, #child_count, #child_index, #contains_child?, #delete_children, #dispatch, #display_value, #find_add_child, #find_child, help, inherited, #initialize, #is_alias?, #is_function?, #msg_reload, #msg_unload, #multiline_value?, #pn, #remove_child, #render, #root?, #send_message, #set_parent, #type_display, #value_display, #value_is_array?, #value_is_blank?, #value_string?

Methods inherited from Core::Baseo

#initialize, #type_display

Constructor Details

This class inherits a constructor from Gloo::Core::Obj

Class Method Details

.messagesObject

Get a list of message names that this object receives.



43
44
45
# File 'lib/gloo/objs/basic/alias.rb', line 43

def self.messages
  return super + %w[resolve]
end

.resolve_alias(engine, obj, ref_name = nil) ⇒ Object

Is the object an alias If so, then resolve it. The ref_name is the name used to refer to the object. If it ends with the * then we won’t resolve the alias since we are trying to refer to the alias itself.



67
68
69
70
71
72
73
74
# File 'lib/gloo/objs/basic/alias.rb', line 67

def self.resolve_alias( engine, obj, ref_name = nil )
  return nil unless obj
  return obj unless obj.type_display == Gloo::Objs::Alias.typename
  return obj if ref_name&.end_with?( ALIAS_REFERENCE )

  ln = Gloo::Core::Pn.new( engine, obj.value )
  return ln.resolve
end

.short_typenameObject

The short name of the object type.



25
26
27
# File 'lib/gloo/objs/basic/alias.rb', line 25

def self.short_typename
  return KEYWORD_SHORT
end

.typenameObject

The name of the object type.



18
19
20
# File 'lib/gloo/objs/basic/alias.rb', line 18

def self.typename
  return KEYWORD
end

Instance Method Details

#msg_resolveObject

Check to see if the referenced object exists.



50
51
52
53
54
55
# File 'lib/gloo/objs/basic/alias.rb', line 50

def msg_resolve
  pn = Gloo::Core::Pn.new( @engine, self.value )
  s = pn.exists?
  @engine.heap.it.set_to s
  return s
end

#set_value(new_value) ⇒ Object

Set the value with any necessary type conversions.



32
33
34
# File 'lib/gloo/objs/basic/alias.rb', line 32

def set_value( new_value )
  self.value = new_value.to_s
end