Class: Vedeu::Cursors::Refresh
- Inherits:
-
Object
- Object
- Vedeu::Cursors::Refresh
- Extended by:
- Forwardable
- Includes:
- Vedeu::Common
- Defined in:
- lib/vedeu/cursors/refresh.rb
Overview
Handle the refreshing (redrawing) of a cursor, without redrawing the whole interface; unless the cursor’s offset has caused the view to change.
Instance Attribute Summary collapse
- #name ⇒ String|Symbol readonly protected
Class Method Summary collapse
Instance Method Summary collapse
-
#absent?(variable) ⇒ Boolean
included
from Vedeu::Common
Returns a boolean indicating whether a variable is nil or empty.
-
#border ⇒ Object
private
Fetch the border by name.
-
#by_name ⇒ Array
Renders the cursor in the terminal.
- #cursor ⇒ Vedeu::Cursors::Cursor private
-
#demodulize(klass) ⇒ String
included
from Vedeu::Common
Removes the module part from the expression in the string.
-
#initialize(name) ⇒ Vedeu::Cursors::Refresh
constructor
Returns a new instance of Vedeu::Cursors::Refresh.
-
#present?(variable) ⇒ Boolean
included
from Vedeu::Common
Returns a boolean indicating whether a variable has a useful value.
-
#refresh_view? ⇒ Boolean
private
Returns true when the view should be refreshed.
-
#snake_case(name) ⇒ String
included
from Vedeu::Common
Converts a class name to a lowercase snake case string.
Constructor Details
#initialize(name) ⇒ Vedeu::Cursors::Refresh
Returns a new instance of Vedeu::Cursors::Refresh.
34 35 36 |
# File 'lib/vedeu/cursors/refresh.rb', line 34 def initialize(name) @name = present?(name) ? name : Vedeu.focus end |
Instance Attribute Details
#name ⇒ String|Symbol (readonly, protected)
54 55 56 |
# File 'lib/vedeu/cursors/refresh.rb', line 54 def name @name end |
Class Method Details
.by_name(name = Vedeu.focus) ⇒ Array
23 24 25 26 27 |
# File 'lib/vedeu/cursors/refresh.rb', line 23 def self.by_name(name = Vedeu.focus) name || Vedeu.focus new(name).by_name end |
Instance Method Details
#absent?(variable) ⇒ Boolean Originally defined in module Vedeu::Common
Returns a boolean indicating whether a variable is nil or empty.
#border ⇒ Object (private)
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.
86 87 88 |
# File 'lib/vedeu/cursors/refresh.rb', line 86 def border @border ||= Vedeu.borders.by_name(name) end |
#by_name ⇒ Array
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.
44 45 46 47 48 |
# File 'lib/vedeu/cursors/refresh.rb', line 44 def by_name Vedeu.trigger(:_refresh_view_content_, name) if refresh_view? cursor.render end |
#cursor ⇒ Vedeu::Cursors::Cursor (private)
69 70 71 |
# File 'lib/vedeu/cursors/refresh.rb', line 69 def cursor @cursor ||= Vedeu.cursors.by_name(name) end |
#demodulize(klass) ⇒ String Originally defined in module Vedeu::Common
Removes the module part from the expression in the string.
#present?(variable) ⇒ Boolean Originally defined in module Vedeu::Common
Returns a boolean indicating whether a variable has a useful value.
#refresh_view? ⇒ Boolean (private)
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.
63 64 65 |
# File 'lib/vedeu/cursors/refresh.rb', line 63 def refresh_view? cursor.ox >= width || cursor.oy >= height end |
#snake_case(name) ⇒ String Originally defined in module Vedeu::Common
Converts a class name to a lowercase snake case string.