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



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

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)


36
37
38
# File 'lib/vedeu/cursors/refresh.rb', line 36

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:

#become(klass, attributes) ⇒ Class 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 one class into another.

Parameters:

  • klass (Class)

    The class to become an instance of.

  • attributes (Hash)

    The attributes of klass.

Returns:

  • (Class)

    Returns a new instance of klass.

#boolean(value) ⇒ 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 the value was a boolean.

Parameters:

  • value (void)

Returns:

#boolean?(value) ⇒ 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 the value is a Boolean.

Parameters:

Returns:

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


55
56
57
58
59
60
61
62
63
# File 'lib/vedeu/cursors/refresh.rb', line 55

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

  Vedeu.log(type:    :cursor,
            message: "Refreshing cursor: '#{name}' (x:#{x}, y:#{y}, " \
                     "ox:#{ox}, oy:#{oy}, visible:#{visible})")

  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


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

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

#escape?(value) ⇒ 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 the value is an escape sequence object (e.g. Vedeu::Cells::Escape.)

Returns:

#falsy?(value) ⇒ 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 the value should be considered false.

Parameters:

  • value (void)

Returns:

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

Fetch the geometry by name.



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

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

#hash?(value) ⇒ 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 the value is a Hash.

Parameters:

  • value (Hash|void)

Returns:

#line_model?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 the model is a Views::Line.

Returns:

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


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

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

#numeric?(value) ⇒ 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 the value is a Fixnum.

Parameters:

  • value (Fixnum|void)

Returns:

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

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



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

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

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

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"

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

Parameters:

  • klass (Module|Class|String)

Returns:

  • (String)

#stream_model?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 the model is a Views::Stream.

Returns:

#string?(value) ⇒ 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 the value is a Fixnum.

Parameters:

  • value (String|void)

Returns:

#truthy?(value) ⇒ 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 the value should be considered true.

Parameters:

  • value (void)

Returns:

#view_model?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 the model is a Views::View.

Returns: