Sha256: e779ba80d7d57c80307737eddef5df689c791bc881b6631c5ac37c121f3bcbea

Contents?: true

Size: 977 Bytes

Versions: 4

Compression:

Stored size: 977 Bytes

Contents

module Vedeu

  # Adjusts the visibility of the cursor.
  #
  class Toggle

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

    # Hides the cursor.
    #
    # @param (see #initialize)
    def self.hide(cursor)
      return cursor if cursor.invisible?

      new(cursor).hide
    end

    # Shows the cursor.
    #
    # @param (see #initialize)
    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

    # @!attribute [r] cursor
    # @return [Vedeu::Cursor]
    attr_reader :cursor

  end # Toggle

end # Vedeu

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vedeu-0.4.13 lib/vedeu/cursor/toggle.rb
vedeu-0.4.12 lib/vedeu/cursor/toggle.rb
vedeu-0.4.11 lib/vedeu/cursor/toggle.rb
vedeu-0.4.10 lib/vedeu/cursor/toggle.rb