Class: Vedeu::Geometries::Geometry
- Inherits:
-
Object
- Object
- Vedeu::Geometries::Geometry
show all
- Extended by:
- Forwardable
- Includes:
- Repositories::Model
- Defined in:
- lib/vedeu/geometries/geometry.rb
Overview
TODO:
Consider storing the Terminal size at the time of first
creation, this allows us to return the interface to its original dimensions if the terminal resizes back to normal size.
Calculates and provides interface geometry determined by both the client’s requirements and the terminal’s current viewing area.
Instance Attribute Summary collapse
Instance Method Summary
collapse
included, #store
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?
Constructor Details
Returns a new instance of Vedeu::Geometries::Geometry.
104
105
106
107
108
|
# File 'lib/vedeu/geometries/geometry.rb', line 104
def initialize(attributes = {})
defaults.merge!(attributes).each do |key, value|
instance_variable_set("@#{key}", value)
end
end
|
Instance Attribute Details
#client ⇒ Object
44
45
46
|
# File 'lib/vedeu/geometries/geometry.rb', line 44
def client
@client
end
|
#height=(value) ⇒ Fixnum
48
49
50
|
# File 'lib/vedeu/geometries/geometry.rb', line 48
def height=(value)
@height = value
end
|
#horizontal_alignment ⇒ Symbol
52
53
54
|
# File 'lib/vedeu/geometries/geometry.rb', line 52
def horizontal_alignment
@horizontal_alignment
end
|
#maximised ⇒ Boolean
Also known as:
maximised?
56
57
58
|
# File 'lib/vedeu/geometries/geometry.rb', line 56
def maximised
@maximised
end
|
#name ⇒ String|Symbol
61
62
63
|
# File 'lib/vedeu/geometries/geometry.rb', line 61
def name
@name
end
|
#vertical_alignment ⇒ Symbol
65
66
67
|
# File 'lib/vedeu/geometries/geometry.rb', line 65
def vertical_alignment
@vertical_alignment
end
|
#width=(value) ⇒ Fixnum
69
70
71
|
# File 'lib/vedeu/geometries/geometry.rb', line 69
def width=(value)
@width = value
end
|
#x=(value) ⇒ Fixnum
73
74
75
|
# File 'lib/vedeu/geometries/geometry.rb', line 73
def x=(value)
@x = value
end
|
#xn=(value) ⇒ Fixnum
77
78
79
|
# File 'lib/vedeu/geometries/geometry.rb', line 77
def xn=(value)
@xn = value
end
|
#y=(value) ⇒ Fixnum
81
82
83
|
# File 'lib/vedeu/geometries/geometry.rb', line 81
def y=(value)
@y = value
end
|
#yn=(value) ⇒ Fixnum
85
86
87
|
# File 'lib/vedeu/geometries/geometry.rb', line 85
def yn=(value)
@yn = value
end
|
Instance Method Details
184
185
186
|
# File 'lib/vedeu/geometries/geometry.rb', line 184
def area
@_area ||= Vedeu::Geometries::Area.from_attributes(attributes)
end
|
#attributes ⇒ Hash<Symbol => Boolean|Fixnum|String|Symbol>
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/vedeu/geometries/geometry.rb', line 111
def attributes
{
client: client,
height: @height.is_a?(Proc) ? @height.call : @height,
horizontal_alignment: horizontal_alignment,
maximised: maximised,
name: name,
vertical_alignment: vertical_alignment,
width: @width.is_a?(Proc) ? @width.call : @width,
x: @x.is_a?(Proc) ? @x.call : @x,
xn: @xn.is_a?(Proc) ? @xn.call : @xn,
y: @y.is_a?(Proc) ? @y.call : @y,
yn: @yn.is_a?(Proc) ? @yn.call : @yn,
}
end
|
#defaults ⇒ Hash<Symbol => void>
The default options/attributes for a new instance of this class.
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
# File 'lib/vedeu/geometries/geometry.rb', line 189
def defaults
{
client: nil,
height: nil,
horizontal_alignment: :none,
maximised: false,
name: nil,
vertical_alignment: :none,
width: nil,
x: nil,
xn: nil,
y: nil,
yn: nil,
}
end
|
Returns a DSL instance responsible for defining the DSL methods of this model.
136
137
138
|
# File 'lib/vedeu/geometries/geometry.rb', line 136
def deputy(client = nil)
Vedeu::Geometries::DSL.new(self, client)
end
|
#eql?(other) ⇒ Boolean
Also known as:
==
An object is equal when its values are the same.
144
145
146
|
# File 'lib/vedeu/geometries/geometry.rb', line 144
def eql?(other)
self.class.equal?(other.class) && name == other.name
end
|
151
152
153
154
155
156
157
158
159
160
|
# File 'lib/vedeu/geometries/geometry.rb', line 151
def maximise
return self if maximised?
@maximised = true
@_area = nil
store do
Vedeu.trigger(:_refresh_view_, name)
end
end
|
177
178
179
|
# File 'lib/vedeu/geometries/geometry.rb', line 177
def repository
Vedeu.geometries
end
|
164
165
166
167
168
169
170
171
172
173
174
|
# File 'lib/vedeu/geometries/geometry.rb', line 164
def unmaximise
return self unless maximised?
@maximised = false
@_area = nil
store do
Vedeu.trigger(:_clear_)
Vedeu.trigger(:_refresh_)
end
end
|