Sha256: 83d3f2f1b8dc678bfccc85e8d3b4154b1c543b2948905242394ed211a83af097

Contents?: true

Size: 1.43 KB

Versions: 23

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

23 entries across 23 versions & 1 rubygems

Version Path
gloo-lang-1.4.3 lib/gloo_lang/objs/basic/container.rb
gloo-lang-1.4.2 lib/gloo_lang/objs/basic/container.rb
gloo-lang-1.4.1 lib/gloo_lang/objs/basic/container.rb
gloo-lang-1.4.0 lib/gloo_lang/objs/basic/container.rb
gloo-lang-1.3.2 lib/gloo_lang/objs/basic/container.rb
gloo-lang-1.3.1 lib/gloo_lang/objs/basic/container.rb
gloo-lang-1.3.0 lib/gloo_lang/objs/basic/container.rb
gloo-lang-1.2.8 lib/gloo_lang/objs/basic/container.rb
gloo-lang-1.2.7 lib/gloo_lang/objs/basic/container.rb
gloo-lang-1.2.6 lib/gloo_lang/objs/basic/container.rb
gloo-lang-1.2.5 lib/gloo_lang/objs/basic/container.rb
gloo-lang-1.2.4 lib/gloo_lang/objs/basic/container.rb
gloo-lang-1.2.3 lib/gloo_lang/objs/basic/container.rb
gloo-lang-1.2.2 lib/gloo_lang/objs/basic/container.rb
gloo-lang-1.2.1 lib/gloo_lang/objs/basic/container.rb
gloo-lang-1.2.0 lib/gloo_lang/objs/basic/container.rb
gloo-lang-1.1.0 lib/gloo_lang/objs/basic/container.rb
gloo-lang-1.0.2 lib/gloo_lang/objs/basic/container.rb
gloo-lang-1.0.1 lib/gloo_lang/objs/basic/container.rb
gloo-lang-1.0.0 lib/gloo_lang/objs/basic/container.rb