Sha256: 6d4f28d632f5a2518bfd91130a3613ebae7bf5d061af9260c233cc9f406cadc1

Contents?: true

Size: 1.18 KB

Versions: 7

Compression:

Stored size: 1.18 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 [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

      # @macro defaults_method
      def defaults
        super.merge!(position: Vedeu::Geometries::Position.new(1, 1))
      end

    end # Cursor

  end # Cells

end # Vedeu

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
vedeu-0.8.18 lib/vedeu/cells/cursor.rb
vedeu-0.8.17 lib/vedeu/cells/cursor.rb
vedeu-0.8.16 lib/vedeu/cells/cursor.rb
vedeu-0.8.15 lib/vedeu/cells/cursor.rb
vedeu-0.8.14 lib/vedeu/cells/cursor.rb
vedeu-0.8.13 lib/vedeu/cells/cursor.rb
vedeu-0.8.12 lib/vedeu/cells/cursor.rb