Class: Vedeu::Cursors::Refresh Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Vedeu::Common
Defined in:
lib/vedeu/cursors/refresh.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.

Handle the refreshing (redrawing) of a cursor, without redrawing the whole interface; unless the cursor's offset has caused the view to change.

API:

  • private

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Vedeu::Common

#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?

Constructor Details

#initialize(name) ⇒ Vedeu::Cursors::Refresh

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 a new instance of Vedeu::Cursors::Refresh.

Parameters:

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

API:

  • private



41
42
43
# File 'lib/vedeu/cursors/refresh.rb', line 41

def initialize(name)
  @name = name
end

Class Method Details

.by_name(name = Vedeu.focus) ⇒ Array

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.

Examples:

Vedeu.trigger(:_refresh_cursor_, name)

Parameters:

  • (defaults to: Vedeu.focus)

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

Returns:

API:

  • private



33
34
35
# File 'lib/vedeu/cursors/refresh.rb', line 33

def self.by_name(name = Vedeu.focus)
  new(name).by_name
end

Instance Method Details

#by_nameArray

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.

Renders the cursor in the terminal. If the cursor's x or y offsets are greater or equal to the interface's width or height respectively, then the view is also refreshed, causing the content to be offset also.

Returns:

API:

  • private



51
52
53
54
55
56
57
58
# File 'lib/vedeu/cursors/refresh.rb', line 51

def by_name
  Vedeu.log(type:    :cursor,
            message: "Refreshing cursor: (#{cursor.inspect})")

  render

  Vedeu.trigger(:_refresh_view_content_, name) if refresh_view?
end

#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.

Returns the named cursor from the cursors repository.

Returns:

API:

  • private



78
79
80
# File 'lib/vedeu/cursors/refresh.rb', line 78

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

#geometryVedeu::Geometries::Geometry (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 the named geometry from the geometries repository.

Returns:

API:

  • private



83
84
85
# File 'lib/vedeu/cursors/refresh.rb', line 83

def geometry
  @_geometry ||= Vedeu.geometries.by_name(name)
end

#nameNilClass|Symbol|String (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 The name of the model, the target model or the name of the associated model.

Returns:

  • The name of the model, the target model or the name of the associated model.

API:

  • private



63
64
65
# File 'lib/vedeu/cursors/refresh.rb', line 63

def name
  present?(@name) ? @name : Vedeu.focus
end

#refresh_view?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 true when the view should be refreshed. This is determined by checking that the offsets for x and y are outside the (bordered) width and (bordered) height of the named interface.

Returns:

API:

  • private



73
74
75
# File 'lib/vedeu/cursors/refresh.rb', line 73

def refresh_view?
  visible? && (ox >= bordered_width || oy >= bordered_height)
end