Sha256: b1942c22883e7cebda94931377a1c8ab375160f9a891aa795f3d091c57b1533b

Contents?: true

Size: 977 Bytes

Versions: 2

Compression:

Stored size: 977 Bytes

Contents

module Vedeu

  # Adjusts the visibility of the cursor.
  #
  class ToggleCursor

    # Returns an instance of ToggleCursor.
    #
    # @param cursor [Cursor]
    # @return [ToggleCursor]
    def initialize(cursor)
      @cursor = cursor
    end

    # Hides the cursor.
    #
    # @param cursor [Cursor]
    # @return [Cursor]
    def self.hide(cursor)
      return cursor if cursor.invisible?

      new(cursor).hide
    end

    # Shows the cursor.
    #
    # @param cursor [Cursor]
    # @return [Cursor]
    def self.show(cursor)
      return cursor if cursor.visible?

      new(cursor).show
    end

    # Hides the cursor.
    #
    # @return [Cursor]
    def hide
      cursor.class.new(cursor.attributes.merge!({ state: false })).store
    end

    # Shows the cursor.
    #
    # @return [Cursor]
    def show
      cursor.class.new(cursor.attributes.merge!({ state: true })).store
    end

    private

    attr_reader :cursor

  end # ToggleCursor

end # Vedeu

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vedeu-0.4.5 lib/vedeu/cursor/toggle_cursor.rb
vedeu-0.4.4 lib/vedeu/cursor/toggle_cursor.rb