Sha256: d6e2ea192f4fdbc07f5c1b0d208d47e84f309e130674bc169b7e26854be0688f

Contents?: true

Size: 1.61 KB

Versions: 16

Compression:

Stored size: 1.61 KB

Contents

# Author::    Eric Crane  (mailto:eric.crane@mac.com)
# Copyright:: Copyright (c) 2020 Eric Crane.  All rights reserved.
#
# Markdown data.
#

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

      KEYWORD = 'markdown'.freeze
      KEYWORD_SHORT = 'md'.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[show page]
      end

      #
      # Show the markdown data in the terminal.
      #
      def msg_show
        @engine.platform.show( self.value, true, false )
      end

      #
      # Show the markdown data in the terminal, paginated.
      #
      def msg_page
        return unless self.value

        @engine.platform.show( md, true, true )
      end

    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

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