Class: Gloo::Objs::Alias
- Inherits:
-
Core::Obj
- Object
- Core::Baseo
- Core::Obj
- Gloo::Objs::Alias
- 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
Attributes inherited from Core::Baseo
Class Method Summary collapse
-
.doc_data ⇒ Object
Get the object's documentation data.
-
.messages ⇒ Object
Get a list of message names that this object receives.
-
.resolve_alias(engine, obj, ref_name = nil) ⇒ Object
Is the object an alias If so, then resolve it.
-
.short_typename ⇒ Object
The short name of the object type.
-
.typename ⇒ Object
The name of the object type.
Instance Method Summary collapse
-
#msg_resolve ⇒ Object
Check to see if the referenced object exists.
-
#set_value(new_value) ⇒ Object
Set the value with any necessary type conversions.
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, #find_child_resolve_alias, #find_child_value, help, inherited, #initialize, #is_alias?, #is_container?, #is_function?, #msg_blank?, #msg_contains?, #msg_reload, #msg_responds_to?, #msg_unload, #multiline_value?, #pn, #remove_child, #render, #root?, #send_message, #set_parent, #sql_value, #type_display, #value_display, #value_is_array?, #value_is_blank?, #value_string?
Methods inherited from Core::Baseo
Constructor Details
This class inherits a constructor from Gloo::Core::Obj
Class Method Details
.doc_data ⇒ Object
Get the object's documentation data.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/gloo/objs/basic/alias.rb', line 83 def self.doc_data { :name => KEYWORD, :shortcut => KEYWORD_SHORT, :description => 'A pointer to another object. Normal ' \ 'path-name references will refer to the aliased object. To ' \ 'refer to the alias itself, add an * at the end of the ' \ 'path-name — needed, for example, to set the value of the ' \ 'alias. The value of the alias is merely the path-name of ' \ 'the referenced object. Well constructed aliases will ' \ 'redirect to the referenced object through any number of ' \ 'steps, and relative references will also work in an alias.', :messages => [ 'resolve — Check to see if the object referenced exists. Sets it to true or false.' ], :notes => 'The alias also reflects (forwards) the messages of the object it points to.', :examples => <<~EXAMPLES.strip # # Alias object. # a [can] : s [string] : a string i [integer] : 13 ln [alias] : a.s on_load [script] : show a.ln show a.ln* put 'a.i' into a.ln* put 7 into a.ln show a.ln run a.add # # Example of creating an object using an alias. # add [script] : put 'x' into a.ln* create a.ln* as string put 'test' into x show a.ln EXAMPLES } end |
.messages ⇒ Object
Get a list of message names that this object receives.
43 44 45 |
# File 'lib/gloo/objs/basic/alias.rb', line 43 def self. 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_typename ⇒ Object
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 |
.typename ⇒ Object
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_resolve ⇒ Object
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 |