Sha256: c8c453f6acdf7df199423ff6bac0aec97d0bba2a74b6b3c22624c5ff3cf6ace2

Contents?: true

Size: 1.43 KB

Versions: 4

Compression:

Stored size: 1.43 KB

Contents

# Author::    Eric Crane  (mailto:eric.crane@mac.com)
# Copyright:: Copyright (c) 2019 Eric Crane.  All rights reserved.
#
# An object that contains a collection of other objects.
#

module GlooLang
  module Objs
    class Container < GlooLang::Core::Obj

      KEYWORD = 'container'.freeze
      KEYWORD_SHORT = 'can'.freeze

      #
      # The name of the object type.
      #
      def self.typename
        return KEYWORD
      end

      #
      # The short name of the object type.
      #
      def self.short_typename
        return KEYWORD_SHORT
      end

      # ---------------------------------------------------------------------
      #    Messages
      # ---------------------------------------------------------------------

      #
      # Get a list of message names that this object receives.
      #
      def self.messages
        return super + %w[count delete_children show_key_value_table]
      end

      #
      # Count the number of children in the container.
      #
      def msg_count
        i = child_count
        $engine.heap.it.set_to i
        return i
      end

      #
      # Delete all children in the container.
      #
      def msg_delete_children
        self.delete_children
      end

      #
      # Show the given table data.
      #
      def msg_show_key_value_table
        data = self.children.map { |o| [ o.name, o.value ] }
        $engine.platform.show_table nil, data, title
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gloo-lang-0.9.8 lib/gloo_lang/objs/basic/container.rb
gloo-lang-0.9.7 lib/gloo_lang/objs/basic/container.rb
gloo-lang-0.9.6 lib/gloo_lang/objs/basic/container.rb
gloo-lang-0.9.5 lib/gloo_lang/objs/basic/container.rb