Sha256: a19971f3fe59bcfc96ded25891c130f5c7cdfe0beb20e08408a5c3b9e97c8291

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

module Vedeu

  module Cells

    # Provides the position and visibility escape sequence for a
    # {Vedeu::Cursors::Cursor}
    #
    # @api private
    #
    class Cursor < Vedeu::Cells::Empty

      include Vedeu::Geometries::Positionable

      # @return [Boolean]
      def cell?
        false
      end

      # @return [NilClass]
      def null
        nil
      end
      alias_method :background, :null
      alias_method :colour,     :null
      alias_method :foreground, :null
      alias_method :style,      :null

      # Return an empty hash as most escape sequences won't make
      # sense as JSON.
      #
      # @return [Hash<void>]
      def to_h
        {}.merge!(position.to_h).merge!(value: value)
      end
      alias_method :to_hash, :to_h

      # Return an empty string as most escape sequences won't make
      # sense as HTML.
      #
      # @param _options [Hash] Ignored.
      # @return [String]
      def to_html(_options = {})
        ''
      end

      # @return [String]
      def to_s
        "#{position}#{value}"
      end
      alias_method :to_str, :to_s

      # @return [Symbol]
      def type
        :cursor
      end

      private

      # @return [Hash]
      def defaults
        super.merge!(position: [1, 1])
      end

    end # Cursor

  end # Cells

end # Vedeu

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vedeu-0.8.4 lib/vedeu/cells/cursor.rb
vedeu-0.8.3 lib/vedeu/cells/cursor.rb