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.

Class Method Summary collapse

Instance Method Summary collapse

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:

  • name (String|Symbol)

    The name of the interface/view cursor to be refreshed. Defaults to ‘Vedeu.focus`.



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

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:

  • name (String|Symbol) (defaults to: Vedeu.focus)

    The name of the interface/view cursor to be refreshed. Defaults to ‘Vedeu.focus`.

Returns:

  • (Array)


25
26
27
# File 'lib/vedeu/cursors/refresh.rb', line 25

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

Instance Method Details

#absent?(variable) ⇒ Boolean Originally defined in module Vedeu::Common

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 boolean indicating whether a variable is nil or empty.

Parameters:

  • variable (String|Symbol|Array|Fixnum)

    The variable to check.

Returns:

  • (Boolean)

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

Note:

Borders::Border is used in this way because when there is not a border defined, it will fallback to a Borders::Null which uses Geometry::Geometry to determine it’s dimensions based on the name also. When a Geometry::Geometry cannot be found, this falls back to a Geometry::Null which uses the dimensions of the current terminal.

Fetch the border by name.



90
91
92
# File 'lib/vedeu/cursors/refresh.rb', line 90

def border
  @border ||= Vedeu.borders.by_name(name)
end

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

  • (Array)


44
45
46
47
48
# File 'lib/vedeu/cursors/refresh.rb', line 44

def by_name
  refresh_view if refresh_view?

  cursor.render
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:

See Also:

  • Vedeu::Cursors::Repository#by_name


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

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

#demodulize(klass) ⇒ String Originally defined in module Vedeu::Common

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.

Removes the module part from the expression in the string.

Examples:

demodulize('Vedeu::SomeModule::SomeClass') # => "SomeClass"

Parameters:

  • klass (Class|String)

Returns:

  • (String)

#nameString|Symbol (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:

  • (String|Symbol)


53
54
55
# File 'lib/vedeu/cursors/refresh.rb', line 53

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

#present?(variable) ⇒ Boolean Originally defined in module Vedeu::Common

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 boolean indicating whether a variable has a useful value.

Parameters:

  • variable (String|Symbol|Array|Fixnum)

    The variable to check.

Returns:

  • (Boolean)

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

This method returns an undefined value.



58
59
60
# File 'lib/vedeu/cursors/refresh.rb', line 58

def refresh_view
  Vedeu.trigger(:_refresh_view_content_, name)
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 width and height of the named interface.

Returns:

  • (Boolean)


67
68
69
# File 'lib/vedeu/cursors/refresh.rb', line 67

def refresh_view?
  cursor.visible? && cursor.ox >= width || cursor.oy >= height
end

#snake_case(name) ⇒ String Originally defined in module Vedeu::Common

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.

Converts a class name to a lowercase snake case string.

Examples:

snake_case(MyClassName) # => "my_class_name"
snake_case(NameSpaced::ClassName)
# => "name_spaced/class_name"

Parameters:

  • name (String)

Returns:

  • (String)