Sha256: 0ec0cd8457e46e9d6e58a2e227a2c940203626c6111d312e2e46a4c6934be8e6

Contents?: true

Size: 1.49 KB

Versions: 17

Compression:

Stored size: 1.49 KB

Contents

# Author::    Eric Crane  (mailto:eric.crane@mac.com)
# Copyright:: Copyright (c) 2019 Eric Crane.  All rights reserved.
#
# A String.
#

module Gloo
  module Objs
    class String < Gloo::Core::Obj

      KEYWORD = 'string'.freeze
      KEYWORD_SHORT = 'str'.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

      #
      # Set the value with any necessary type conversions.
      #
      def set_value( new_value )
        self.value = new_value.to_s
      end

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

      #
      # Get a list of message names that this object receives.
      #
      def self.messages
        return super + %w[up down size]
      end

      #
      # Get the size of the string.
      #
      def msg_size
        s = value.size
        @engine.heap.it.set_to s
        return s
      end

      #
      # Convert string to upper case
      #
      def msg_up
        s = value.upcase
        set_value s
        @engine.heap.it.set_to s
        return s
      end

      #
      # Convert string to lower case
      #
      def msg_down
        s = value.downcase
        set_value s
        @engine.heap.it.set_to s
        return s
      end

    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
gloo-3.3.0 lib/gloo/objs/basic/string.rb
gloo-3.2.0 lib/gloo/objs/basic/string.rb
gloo-3.1.1 lib/gloo/objs/basic/string.rb
gloo-3.1.0 lib/gloo/objs/basic/string.rb
gloo-3.0.1 lib/gloo/objs/basic/string.rb
gloo-3.0.0 lib/gloo/objs/basic/string.rb
gloo-2.5.0 lib/gloo/objs/basic/string.rb
gloo-2.4.3 lib/gloo/objs/basic/string.rb
gloo-2.4.2 lib/gloo/objs/basic/string.rb
gloo-2.4.1 lib/gloo/objs/basic/string.rb
gloo-2.4.0 lib/gloo/objs/basic/string.rb
gloo-2.3.1 lib/gloo/objs/basic/string.rb
gloo-2.2.0 lib/gloo/objs/basic/string.rb
gloo-2.1.0 lib/gloo/objs/basic/string.rb
gloo-2.0.2 lib/gloo/objs/basic/string.rb
gloo-2.0.1 lib/gloo/objs/basic/string.rb
gloo-2.0.0 lib/gloo/objs/basic/string.rb