Class: Gloo::Objs::Container

Inherits:
Core::Obj show all
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

#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, #set_value, #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.



35
36
37
# File 'lib/gloo/objs/basic/container.rb', line 35

def self.messages
  return super + %w[count delete_children child_exists show_key_value_table]
end

.short_typenameObject

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

.typenameObject

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_existsObject

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_countObject

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_childrenObject

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_tableObject

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