Sha256: c0beb971a0cd8fac51f9a3d41092d63fa895506af1a9e225f3966c7f5d6f7646

Contents?: true

Size: 1.49 KB

Versions: 9

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

9 entries across 9 versions & 1 rubygems

Version Path
gloo-0.8.0 lib/gloo/objs/basic/string.rb
gloo-0.7.7 lib/gloo/objs/basic/string.rb
gloo-0.7.6 lib/gloo/objs/basic/string.rb
gloo-0.7.5 lib/gloo/objs/basic/string.rb
gloo-0.7.4 lib/gloo/objs/basic/string.rb
gloo-0.7.3 lib/gloo/objs/basic/string.rb
gloo-0.7.2 lib/gloo/objs/basic/string.rb
gloo-0.7.1 lib/gloo/objs/basic/string.rb
gloo-0.7.0 lib/gloo/objs/basic/string.rb