Class: Vedeu::Geometries::Move Private
- Inherits:
-
Object
- Object
- Vedeu::Geometries::Move
- Extended by:
- Forwardable
- Includes:
- Repositories::Defaults
- Defined in:
- lib/vedeu/geometries/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.
Move an interface/view via changing its geometry.
When moving an interface/view;
1) Reset the alignment and maximised states to false;
it wont be aligned to a side if moved, and cannot be moved
if maximised.
2) Get the current coordinates of the interface, then: 3) Override the attributes with the new coordinates for
desired movement; these are usually +/- 1 of the current
state, depending on direction.
Instance Attribute Summary collapse
-
#direction ⇒ Symbol
readonly
protected
private
The direction to move; one of: :down, :left, :origin, :right, :up.
-
#name ⇒ String|Symbol
readonly
protected
private
The name of the interface/view.
-
#offset ⇒ Symbol
readonly
protected
private
The number of columns or rows to move by.
Class Method Summary collapse
Instance Method Summary collapse
-
#absent?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable is nil or empty.
-
#become(klass, attributes) ⇒ Class
included
from Common
private
Converts one class into another.
-
#boolean(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating the value was a boolean.
-
#boolean?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Boolean.
- #defaults ⇒ Hash<Symbol => Fixnum|String|Symbol> private private
- #direction? ⇒ Boolean private private
-
#down ⇒ Hash<Symbol => Fixnum]
private
private
Moves the geometry down by the offset.
-
#escape?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is an escape sequence object (e.g. Cells::Escape.).
- #event ⇒ Hash<Symbol => Symbol> private private
-
#falsy?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value should be considered false.
- #geometry ⇒ Vedeu::Geometries::Geometry private private
-
#hash?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Hash.
-
#initialize(attributes = {}) ⇒ void
included
from Repositories::Defaults
private
Returns a new instance of the class including this module.
-
#left ⇒ Hash<Symbol => Fixnum]
private
private
Moves the geometry left by the offset.
-
#line_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::Line.
- #move ⇒ Boolean|Vedeu::Geometries::Geometry private
- #new_attributes ⇒ Hash<Symbol => Boolean|String|Symbol> private private
-
#numeric?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Fixnum.
-
#origin ⇒ Hash<Symbol => Fixnum]
private
private
Moves the geometry to the top left of the terminal.
-
#present?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable has a useful value.
-
#refresh! ⇒ void
private
private
Refresh the screen after moving.
-
#right ⇒ Hash<Symbol => Fixnum]
private
private
Moves the geometry right by the offset.
-
#snake_case(klass) ⇒ String
included
from Common
private
Converts a class name to a lowercase snake case string.
-
#stream_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::Stream.
-
#string?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Fixnum.
-
#truthy?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value should be considered true.
-
#unalign_unmaximise ⇒ Hash<Symbol => Boolean|Symbol]
private
private
Hash<Symbol => Boolean|Symbol].
-
#up ⇒ Hash<Symbol => Fixnum]
private
private
Moves the geometry up by the offset.
-
#update_cursor! ⇒ void
private
private
Refresh the cursor after moving.
- #valid? ⇒ Boolean private private
- #valid_down? ⇒ Boolean private private
- #valid_left? ⇒ Boolean private private
- #valid_right? ⇒ Boolean private private
- #valid_up? ⇒ Boolean private private
- #validate(attributes) ⇒ Hash included from Repositories::Defaults private private
-
#view_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::View.
Instance Attribute Details
#direction ⇒ 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 direction to move; one of: :down, :left, :origin, :right, :up.
53 54 55 |
# File 'lib/vedeu/geometries/move.rb', line 53 def direction @direction end |
#name ⇒ String|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 interface/view.
57 58 59 |
# File 'lib/vedeu/geometries/move.rb', line 57 def name @name end |
#offset ⇒ 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 number of columns or rows to move by.
61 62 63 |
# File 'lib/vedeu/geometries/move.rb', line 61 def offset @offset end |
Class Method Details
.move(attributes = {}) ⇒ Boolean|Vedeu::Geometries::Geometry
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 |
# File 'lib/vedeu/geometries/move.rb', line 34 def self.move(attributes = {}) new(attributes).move end |
Instance Method Details
#absent?(variable) ⇒ Boolean Originally defined in module 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.
#become(klass, attributes) ⇒ Class Originally defined in module 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.
#boolean(value) ⇒ Boolean Originally defined in module 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.
#boolean?(value) ⇒ Boolean Originally defined in module 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.
#defaults ⇒ Hash<Symbol => Fixnum|String|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.
66 67 68 69 70 71 72 |
# File 'lib/vedeu/geometries/move.rb', line 66 def defaults { direction: :none, name: '', offset: 1, } end |
#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.
75 76 77 |
# File 'lib/vedeu/geometries/move.rb', line 75 def direction? direction != :none end |
#down ⇒ Hash<Symbol => Fixnum] (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.
Moves the geometry down by the offset.
82 83 84 85 86 87 |
# File 'lib/vedeu/geometries/move.rb', line 82 def down { y: y + offset, yn: yn + offset, } end |
#escape?(value) ⇒ Boolean Originally defined in module 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.)
#event ⇒ Hash<Symbol => 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.
90 91 92 93 94 95 96 97 98 |
# File 'lib/vedeu/geometries/move.rb', line 90 def event { down: :_cursor_down_, left: :_cursor_left_, origin: :_cursor_origin_, right: :_cursor_right_, up: :_cursor_up_, }[direction] end |
#falsy?(value) ⇒ Boolean Originally defined in module 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.
#geometry ⇒ Vedeu::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.
101 102 103 |
# File 'lib/vedeu/geometries/move.rb', line 101 def geometry @geometry ||= Vedeu.geometries.by_name(name) end |
#hash?(value) ⇒ Boolean Originally defined in module 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.
#initialize(attributes = {}) ⇒ void Originally defined in module Repositories::Defaults
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.
If a particular key is missing from the attributes parameter, then it is added with the respective value from #defaults.
Returns a new instance of the class including this module.
#left ⇒ Hash<Symbol => Fixnum] (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.
Moves the geometry left by the offset.
108 109 110 111 112 113 |
# File 'lib/vedeu/geometries/move.rb', line 108 def left { x: x - offset, xn: xn - offset, } end |
#line_model? ⇒ Boolean Originally defined in module 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.
#move ⇒ Boolean|Vedeu::Geometries::Geometry
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.
39 40 41 42 43 44 45 46 |
# File 'lib/vedeu/geometries/move.rb', line 39 def move return false unless valid? Vedeu::Geometries::Geometry.store(new_attributes) do update_cursor! refresh! end end |
#new_attributes ⇒ Hash<Symbol => Boolean|String|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.
116 117 118 |
# File 'lib/vedeu/geometries/move.rb', line 116 def new_attributes geometry.attributes.merge!(unalign_unmaximise).merge!(send(direction)) end |
#numeric?(value) ⇒ Boolean Originally defined in module 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.
#origin ⇒ Hash<Symbol => Fixnum] (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.
Moves the geometry to the top left of the terminal.
123 124 125 126 127 128 129 130 |
# File 'lib/vedeu/geometries/move.rb', line 123 def origin { x: 1, xn: (xn - x + 1), y: 1, yn: (yn - y + 1), } end |
#present?(variable) ⇒ Boolean Originally defined in module 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.
#refresh! ⇒ void (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.
Refresh the screen after moving.
135 136 137 |
# File 'lib/vedeu/geometries/move.rb', line 135 def refresh! Vedeu.trigger(:_movement_refresh_, name) end |
#right ⇒ Hash<Symbol => Fixnum] (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.
Moves the geometry right by the offset.
142 143 144 145 146 147 |
# File 'lib/vedeu/geometries/move.rb', line 142 def right { x: x + offset, xn: xn + offset, } end |
#snake_case(klass) ⇒ String Originally defined in module 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.
#stream_model? ⇒ Boolean Originally defined in module 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.
#string?(value) ⇒ Boolean Originally defined in module 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.
#truthy?(value) ⇒ Boolean Originally defined in module 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.
#unalign_unmaximise ⇒ Hash<Symbol => Boolean|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 Hash<Symbol => Boolean|Symbol].
150 151 152 153 154 155 156 |
# File 'lib/vedeu/geometries/move.rb', line 150 def unalign_unmaximise { horizontal_alignment: :none, maximised: false, vertical_alignment: :none, } end |
#up ⇒ Hash<Symbol => Fixnum] (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.
Moves the geometry up by the offset.
161 162 163 164 165 166 |
# File 'lib/vedeu/geometries/move.rb', line 161 def up { y: y - offset, yn: yn - offset, } end |
#update_cursor! ⇒ void (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.
Refresh the cursor after moving.
171 172 173 |
# File 'lib/vedeu/geometries/move.rb', line 171 def update_cursor! Vedeu.trigger(event, name) end |
#valid? ⇒ 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.
176 177 178 179 180 181 182 183 184 |
# File 'lib/vedeu/geometries/move.rb', line 176 def valid? { down: valid_down?, left: valid_left?, origin: true, right: valid_right?, up: valid_up?, }.fetch(direction, false) end |
#valid_down? ⇒ 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.
187 188 189 |
# File 'lib/vedeu/geometries/move.rb', line 187 def valid_down? yn + offset <= Vedeu.height end |
#valid_left? ⇒ 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.
192 193 194 |
# File 'lib/vedeu/geometries/move.rb', line 192 def valid_left? x - offset >= 1 end |
#valid_right? ⇒ 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.
197 198 199 |
# File 'lib/vedeu/geometries/move.rb', line 197 def valid_right? xn + offset <= Vedeu.width end |
#valid_up? ⇒ 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.
202 203 204 |
# File 'lib/vedeu/geometries/move.rb', line 202 def valid_up? y - offset >= 1 end |
#validate(attributes) ⇒ Hash (private) Originally defined in module Repositories::Defaults
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.
#view_model? ⇒ Boolean Originally defined in module 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.