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 ⇒ NilClass|Symbol|String
readonly
protected
private
The name of the model, the target model or the name of the associated model.
-
#offset ⇒ Symbol
readonly
protected
private
The number of columns or rows to move by.
Class Method Summary collapse
Instance Method Summary collapse
- #cursor_event ⇒ Hash<Symbol => Symbol> private private
-
#defaults ⇒ Hash<Symbol => void>
private
private
The default options/attributes for a new instance of this class.
- #direction? ⇒ Boolean private private
- #directional_move ⇒ Hash<Symbol => Hash<Symbol => Fixnum>> private private
- #down ⇒ Hash<Symbol => Fixnum> private private
-
#geometry ⇒ Vedeu::Geometries::Geometry
private
private
Returns the named geometry from the geometries repository.
- #left ⇒ Hash<Symbol => Fixnum> private private
- #move ⇒ Boolean|Vedeu::Geometries::Geometry private
-
#movement ⇒ Hash<Symbol => Hash<Symbol => Fixnum>>
private
private
Moves the geometry in the direction given by the offset also given.
- #new_attributes ⇒ Hash<Symbol => Boolean|String|Symbol> private private
- #origin ⇒ Hash<Symbol => Fixnum> private private
- #right ⇒ Hash<Symbol => Fixnum> private private
-
#unalign_unmaximise ⇒ Hash<Symbol => Boolean|Symbol]
private
private
Hash<Symbol => Boolean|Symbol].
- #up ⇒ Hash<Symbol => Fixnum> private private
-
#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
Methods included from Repositories::Defaults
Methods included from Common
#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?
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 ⇒ NilClass|Symbol|String (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 model, the target model or the name of the associated model.
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
#cursor_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.
66 67 68 69 70 71 72 73 74 |
# File 'lib/vedeu/geometries/move.rb', line 66 def cursor_event { down: :_cursor_down_, left: :_cursor_left_, origin: :_cursor_origin_, right: :_cursor_right_, up: :_cursor_up_, }[direction] end |
#defaults ⇒ Hash<Symbol => 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.
The default options/attributes for a new instance of this class.
77 78 79 80 81 82 83 |
# File 'lib/vedeu/geometries/move.rb', line 77 def defaults { direction: :none, name: nil, 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.
86 87 88 |
# File 'lib/vedeu/geometries/move.rb', line 86 def direction? direction != :none end |
#directional_move ⇒ Hash<Symbol => 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.
91 92 93 |
# File 'lib/vedeu/geometries/move.rb', line 91 def directional_move movement.fetch(direction, {}) 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.
96 97 98 99 100 101 |
# File 'lib/vedeu/geometries/move.rb', line 96 def down { y: y + offset, yn: yn + offset, } end |
#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.
Returns the named geometry from the geometries repository.
104 105 106 |
# File 'lib/vedeu/geometries/move.rb', line 104 def geometry @geometry ||= Vedeu.geometries.by_name(name) end |
#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.
109 110 111 112 113 114 |
# File 'lib/vedeu/geometries/move.rb', line 109 def left { x: x - offset, xn: xn - offset, } end |
#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! Vedeu.trigger(:_movement_refresh_, name) end end |
#movement ⇒ Hash<Symbol => 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 in the direction given by the offset also given.
120 121 122 123 124 125 126 127 128 129 |
# File 'lib/vedeu/geometries/move.rb', line 120 def movement { down: down, left: left, none: {}, origin: origin, right: right, up: up, } 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.
132 133 134 |
# File 'lib/vedeu/geometries/move.rb', line 132 def new_attributes geometry.attributes.merge!(unalign_unmaximise) 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.
137 138 139 140 141 142 143 144 |
# File 'lib/vedeu/geometries/move.rb', line 137 def origin { x: 1, xn: (xn - x + 1), y: 1, yn: (yn - y + 1), } 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.
147 148 149 150 151 152 |
# File 'lib/vedeu/geometries/move.rb', line 147 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].
155 156 157 158 159 160 161 |
# File 'lib/vedeu/geometries/move.rb', line 155 def unalign_unmaximise { horizontal_alignment: :none, maximised: false, vertical_alignment: :none, }.merge(directional_move) 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.
164 165 166 167 168 169 |
# File 'lib/vedeu/geometries/move.rb', line 164 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.
174 175 176 177 178 179 180 181 182 |
# File 'lib/vedeu/geometries/move.rb', line 174 def update_cursor! if direction == :origin Vedeu.trigger(cursor_event, name) else Vedeu.trigger(cursor_event, name, 0) end 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.
185 186 187 188 189 190 191 192 193 194 |
# File 'lib/vedeu/geometries/move.rb', line 185 def valid? { down: valid_down?, left: valid_left?, origin: true, none: false, 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.
197 198 199 |
# File 'lib/vedeu/geometries/move.rb', line 197 def valid_down? Vedeu::Point.valid?(value: yn + offset, max: 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.
202 203 204 |
# File 'lib/vedeu/geometries/move.rb', line 202 def valid_left? Vedeu::Point.valid?(value: x - offset, min: 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.
207 208 209 |
# File 'lib/vedeu/geometries/move.rb', line 207 def valid_right? Vedeu::Point.valid?(value: xn + offset, max: Vedeu.width) end |