Sha256: 3edb965d244bd84be1effe050f185623de15e1bf5c02dce9c9450e745f0bbe16

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 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

      # @return [Boolean]
      def cell?
        false
      end

      # @return [NilClass]
      def null
        nil
      end
      alias background null
      alias colour null
      alias foreground null
      alias 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 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 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.8 lib/vedeu/cells/cursor.rb
vedeu-0.8.7 lib/vedeu/cells/cursor.rb