Sha256: d3cd1eadf0a61642870c4218d8485fec1710bdd80334325525c57cb208e3547d

Contents?: true

Size: 1.62 KB

Versions: 23

Compression:

Stored size: 1.62 KB

Contents

# Author::    Eric Crane  (mailto:eric.crane@mac.com)
# Copyright:: Copyright (c) 2019 Eric Crane.  All rights reserved.
#
# A [multiline] block of text.
#

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

      KEYWORD = 'text'.freeze
      KEYWORD_SHORT = 'txt'.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

      #
      # Does this object support multi-line values?
      # Initially only true for scripts.
      #
      def multiline_value?
        return false
      end

      #
      # Get the number of lines of text.
      #
      def line_count
        return value.split( "\n" ).count
      end

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

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

      #
      # Show the contents of the file, paginated.
      #
      def msg_page
        return unless value

        @engine.platform.show( value, false, true )
      end

      #
      # Edit the text in the default editor.
      #
      def msg_edit
        self.value = @engine.platform.edit( self.value )
      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/text.rb
gloo-lang-1.4.2 lib/gloo_lang/objs/basic/text.rb
gloo-lang-1.4.1 lib/gloo_lang/objs/basic/text.rb
gloo-lang-1.4.0 lib/gloo_lang/objs/basic/text.rb
gloo-lang-1.3.2 lib/gloo_lang/objs/basic/text.rb
gloo-lang-1.3.1 lib/gloo_lang/objs/basic/text.rb
gloo-lang-1.3.0 lib/gloo_lang/objs/basic/text.rb
gloo-lang-1.2.8 lib/gloo_lang/objs/basic/text.rb
gloo-lang-1.2.7 lib/gloo_lang/objs/basic/text.rb
gloo-lang-1.2.6 lib/gloo_lang/objs/basic/text.rb
gloo-lang-1.2.5 lib/gloo_lang/objs/basic/text.rb
gloo-lang-1.2.4 lib/gloo_lang/objs/basic/text.rb
gloo-lang-1.2.3 lib/gloo_lang/objs/basic/text.rb
gloo-lang-1.2.2 lib/gloo_lang/objs/basic/text.rb
gloo-lang-1.2.1 lib/gloo_lang/objs/basic/text.rb
gloo-lang-1.2.0 lib/gloo_lang/objs/basic/text.rb
gloo-lang-1.1.0 lib/gloo_lang/objs/basic/text.rb
gloo-lang-1.0.2 lib/gloo_lang/objs/basic/text.rb
gloo-lang-1.0.1 lib/gloo_lang/objs/basic/text.rb
gloo-lang-1.0.0 lib/gloo_lang/objs/basic/text.rb