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
Instance Attribute Summary
Attributes inherited from Core::Obj
Attributes inherited from Core::Baseo
Class Method Summary collapse
-
.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_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, #contains_child?, #delete_children, #dispatch, #display_value, #find_add_child, #find_child, help, inherited, #initialize, #msg_unload, #multiline_value?, #pn, #remove_child, #root?, #send_message, #set_parent, #set_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
.messages ⇒ Object
Get a list of message names that this object receives.
37 38 39 |
# File 'lib/gloo/objs/basic/container.rb', line 37 def self. return super + %w[count delete_children show_key_value_table] end |
.short_typename ⇒ Object
The short name of the object type.
26 27 28 |
# File 'lib/gloo/objs/basic/container.rb', line 26 def self.short_typename return KEYWORD_SHORT end |
.typename ⇒ Object
The name of the object type.
19 20 21 |
# File 'lib/gloo/objs/basic/container.rb', line 19 def self.typename return KEYWORD end |
Instance Method Details
#msg_count ⇒ Object
Count the number of children in the container.
44 45 46 47 48 |
# File 'lib/gloo/objs/basic/container.rb', line 44 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.
53 54 55 |
# File 'lib/gloo/objs/basic/container.rb', line 53 def msg_delete_children self.delete_children end |
#msg_show_key_value_table ⇒ Object
Show the given table data.
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/gloo/objs/basic/container.rb', line 60 def msg_show_key_value_table data = self.children.map { |o| [ o.name, o.value ] } pastel = ::Pastel.new table = TTY::Table.new rows: data pad = [ 0, 1, 0, 1 ] rendered = table.render( :ascii, indent: 2, padding: pad ) do |r| r.border.style = :blue r.filter = proc do |val, _row_index, col_index| col_index.zero? ? pastel.blue( val ) : pastel.white( val ) end end puts "\n #{rendered}\n\n" end |