Class: Gloo::Objs::Container
- Inherits:
-
Core::Obj
- Object
- Core::Baseo
- Core::Obj
- Gloo::Objs::Container
- Defined in:
- lib/gloo/objs/basic/container.rb
Constant Summary collapse
- KEYWORD =
'container'.freeze
- KEYWORD_SHORT =
'can'.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.
-
.short_typename ⇒ Object
The short name of the object type.
-
.typename ⇒ Object
The name of the object type.
Instance Method Summary collapse
-
#msg_child_exists ⇒ Object
Check to see if there is a child with the given name.
-
#msg_count ⇒ Object
Count the number of children in the container.
-
#msg_delete_children ⇒ Object
Delete all children in the container.
-
#msg_show_key_value_table ⇒ Object
Show the given table data.
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, #set_value, #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.
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 |
# File 'lib/gloo/objs/basic/container.rb', line 86 def self.doc_data { :name => KEYWORD, :shortcut => KEYWORD_SHORT, :description => 'A container of other objects. A container is ' \ 'similar to a folder in a file system. It can contain any ' \ 'number of objects including other containers. The ' \ 'container structure provides direct access to any object ' \ 'within it through the object.object.object path-name structure.', :children => [ 'None by default — but any container can have any number of objects added to it, at runtime.' ], :messages => [ 'count — Count the number of children objects in the container. The result is put in it.', 'delete_children — Delete all children objects from the container.', 'show_key_value_table — Show a table with key (name) and values for all children in the container.', 'child_exists ({name}) — Check to see if there is a child with the given name. A parameter is required. It will have a boolean.' ], :examples => <<~EXAMPLES.strip can [can] : data [can] : 1 : one 2 : two 3 : three on_load [script] : tell can.data to show_key_value_table EXAMPLES } end |
.messages ⇒ Object
Get a list of message names that this object receives.
35 36 37 |
# File 'lib/gloo/objs/basic/container.rb', line 35 def self. return super + %w[count delete_children child_exists show_key_value_table] end |
.short_typename ⇒ Object
The short name of the object type.
24 25 26 |
# File 'lib/gloo/objs/basic/container.rb', line 24 def self.short_typename return KEYWORD_SHORT end |
.typename ⇒ Object
The name of the object type.
17 18 19 |
# File 'lib/gloo/objs/basic/container.rb', line 17 def self.typename return KEYWORD end |
Instance Method Details
#msg_child_exists ⇒ Object
Check to see if there is a child with the given name.
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/gloo/objs/basic/container.rb', line 67 def msg_child_exists if @params&.token_count&.positive? expr = Gloo::Expr::Expression.new( @engine, @params.tokens ) data = expr.evaluate end return unless data val = self.contains_child?( data ) @engine.heap.it.set_to val return val end |
#msg_count ⇒ Object
Count the number of children in the container.
42 43 44 45 46 |
# File 'lib/gloo/objs/basic/container.rb', line 42 def msg_count i = child_count @engine.heap.it.set_to i return i end |
#msg_delete_children ⇒ Object
Delete all children in the container.
51 52 53 |
# File 'lib/gloo/objs/basic/container.rb', line 51 def msg_delete_children self.delete_children end |
#msg_show_key_value_table ⇒ Object
Show the given table data.
58 59 60 61 62 |
# File 'lib/gloo/objs/basic/container.rb', line 58 def msg_show_key_value_table data = self.children.map { |o| [ o.name, o.value ] } @engine.platform.table.show [], data end |