Sha256: 18076120302bbd6667556e3424d224d5cc8e38996acb6ea22d32860005cd3d9f

Contents?: true

Size: 1.62 KB

Versions: 4

Compression:

Stored size: 1.62 KB

Contents

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

module GlooLang
  module Objs
    class Markdown < GlooLang::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

4 entries across 4 versions & 1 rubygems

Version Path
gloo-lang-0.9.8 lib/gloo_lang/objs/data/markdown.rb
gloo-lang-0.9.7 lib/gloo_lang/objs/data/markdown.rb
gloo-lang-0.9.6 lib/gloo_lang/objs/data/markdown.rb
gloo-lang-0.9.5 lib/gloo_lang/objs/data/markdown.rb