Class: Vedeu::Geometry::Move Private
- Inherits:
-
Object
- Object
- Vedeu::Geometry::Move
- Extended by:
- Forwardable
- Includes:
- Repositories::Defaults
- Defined in:
- lib/vedeu/geometry/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
-
.move(attributes = {}) ⇒ Object
private
See #move.
Instance Method Summary collapse
- #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.
- #event ⇒ Hash<Symbol => Symbol> private private
- #geometry ⇒ Vedeu::Geometry::Geometry private private
-
#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.
- #move ⇒ FalseClass|Vedeu::Geometry::Geometry private
- #new_attributes ⇒ Hash<Symbol => Boolean|String|Symbol> private private
-
#origin ⇒ Hash<Symbol => Fixnum]
private
private
Moves the geometry to the top left of the terminal.
-
#refresh! ⇒ void
private
private
Refresh the screen after moving.
-
#right ⇒ Hash<Symbol => Fixnum]
private
private
Moves the geometry right by the offset.
-
#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
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.
51 52 53 |
# File 'lib/vedeu/geometry/move.rb', line 51 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.
55 56 57 |
# File 'lib/vedeu/geometry/move.rb', line 55 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.
59 60 61 |
# File 'lib/vedeu/geometry/move.rb', line 59 def offset @offset end |
Class Method Details
.move(attributes = {}) ⇒ Object
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 #move.
32 33 34 |
# File 'lib/vedeu/geometry/move.rb', line 32 def self.move(attributes = {}) new(attributes).move end |
Instance Method Details
#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.
64 65 66 67 68 69 70 |
# File 'lib/vedeu/geometry/move.rb', line 64 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.
73 74 75 |
# File 'lib/vedeu/geometry/move.rb', line 73 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.
80 81 82 83 84 85 |
# File 'lib/vedeu/geometry/move.rb', line 80 def down { y: y + offset, yn: yn + offset, } end |
#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.
88 89 90 91 92 93 94 95 96 |
# File 'lib/vedeu/geometry/move.rb', line 88 def event { down: :_cursor_down_, left: :_cursor_left_, origin: :_cursor_origin_, right: :_cursor_right_, up: :_cursor_up_, }[direction] end |
#geometry ⇒ Vedeu::Geometry::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.
99 100 101 |
# File 'lib/vedeu/geometry/move.rb', line 99 def geometry Vedeu.geometries.by_name(name) end |
#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.
106 107 108 109 110 111 |
# File 'lib/vedeu/geometry/move.rb', line 106 def left { x: x - offset, xn: xn - offset, } end |
#move ⇒ FalseClass|Vedeu::Geometry::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.
37 38 39 40 41 42 43 44 |
# File 'lib/vedeu/geometry/move.rb', line 37 def move return false unless valid? Vedeu::Geometry::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.
114 115 116 |
# File 'lib/vedeu/geometry/move.rb', line 114 def new_attributes geometry.attributes.merge!(unalign_unmaximise).merge!(send(direction)) end |
#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.
121 122 123 124 125 126 127 128 |
# File 'lib/vedeu/geometry/move.rb', line 121 def origin { x: 1, xn: (xn - x + 1), y: 1, yn: (yn - y + 1), } end |
#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.
133 134 135 |
# File 'lib/vedeu/geometry/move.rb', line 133 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.
140 141 142 143 144 145 |
# File 'lib/vedeu/geometry/move.rb', line 140 def right { x: x + offset, xn: xn + offset, } end |
#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].
148 149 150 151 152 153 154 |
# File 'lib/vedeu/geometry/move.rb', line 148 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.
159 160 161 162 163 164 |
# File 'lib/vedeu/geometry/move.rb', line 159 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.
169 170 171 |
# File 'lib/vedeu/geometry/move.rb', line 169 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.
174 175 176 177 178 179 180 181 182 |
# File 'lib/vedeu/geometry/move.rb', line 174 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.
185 186 187 |
# File 'lib/vedeu/geometry/move.rb', line 185 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.
190 191 192 |
# File 'lib/vedeu/geometry/move.rb', line 190 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.
195 196 197 |
# File 'lib/vedeu/geometry/move.rb', line 195 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.
200 201 202 |
# File 'lib/vedeu/geometry/move.rb', line 200 def valid_up? y - offset >= 1 end |