Sha256: fe8af4a9558c4b7784447a5df22efc5b788e51923d1bd18e17b5506f43f67851

Contents?: true

Size: 1.61 KB

Versions: 17

Compression:

Stored size: 1.61 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 Gloo
  module Objs
    class Text < Gloo::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

17 entries across 17 versions & 1 rubygems

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