Class: Vedeu::Cursors::Move Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/vedeu/cursors/move.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Provides the mechanism to move a named cursor in a given direction.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, direction, offset) ⇒ Vedeu::Cursors::Move

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • name (NilClass|Symbol|String)

    The name of the model or target model to act upon. May default to ‘Vedeu.focus`.

  • direction (Symbol)
  • offset (Fixnum)


29
30
31
32
33
# File 'lib/vedeu/cursors/move.rb', line 29

def initialize(name, direction, offset)
  @name      = name
  @direction = direction
  @offset    = offset
end

Instance Attribute Details

#directionSymbol (readonly, protected)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The direction to move the cursor.

Returns:

  • (Symbol)

    The direction to move the cursor.



52
53
54
# File 'lib/vedeu/cursors/move.rb', line 52

def direction
  @direction
end

#nameString|Symbol (readonly, protected)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The name of the cursor.

Returns:

  • (String|Symbol)

    The name of the cursor.



48
49
50
# File 'lib/vedeu/cursors/move.rb', line 48

def name
  @name
end

#offsetSymbol (readonly, protected)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The number of characters to move the cursor in the given direction.

Returns:

  • (Symbol)

    The number of characters to move the cursor in the given direction.



57
58
59
# File 'lib/vedeu/cursors/move.rb', line 57

def offset
  @offset
end

Class Method Details

.move(name, direction, offset) ⇒ NilClass|Vedeu::Cursors::Cursor

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • name (NilClass|Symbol|String)

    The name of the model or target model to act upon. May default to ‘Vedeu.focus`.

  • direction (Symbol)
  • offset (Fixnum)

Returns:



21
22
23
# File 'lib/vedeu/cursors/move.rb', line 21

def self.move(name, direction, offset)
  new(name, direction, offset).move
end

Instance Method Details

#cursorVedeu::Cursors::Cursor (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



62
63
64
# File 'lib/vedeu/cursors/move.rb', line 62

def cursor
  @_cursor ||= Vedeu.cursors.by_name(name)
end

#moveNilClass|Vedeu::Cursors::Cursor

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



36
37
38
39
40
41
42
# File 'lib/vedeu/cursors/move.rb', line 36

def move
  return nil unless visible? && valid_direction?

  cursor.public_send(direction, offset)
  cursor.store { Vedeu.trigger(:_refresh_cursor_, name) }
  cursor
end

#valid_direction?Boolean (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



67
68
69
70
71
72
73
74
# File 'lib/vedeu/cursors/move.rb', line 67

def valid_direction?
  [
    :move_down,
    :move_left,
    :move_right,
    :move_up,
  ].include?(direction)
end