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) ⇒ 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.



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

def initialize(name, direction)
  @name      = name
  @direction = direction
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.



50
51
52
# File 'lib/vedeu/cursors/move.rb', line 50

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.



46
47
48
# File 'lib/vedeu/cursors/move.rb', line 46

def name
  @name
end

Class Method Details

.move(name, direction) ⇒ 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.



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

def self.move(name, direction)
  new(name, direction).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.



55
56
57
# File 'lib/vedeu/cursors/move.rb', line 55

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.



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

def move
  return nil unless visible? && valid_direction?

  cursor.public_send(direction)
  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.



60
61
62
63
64
65
66
67
# File 'lib/vedeu/cursors/move.rb', line 60

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