Class: Vedeu::Geometries::Geometry Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Repositories::Model
Defined in:
lib/vedeu/geometries/geometry.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.

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

Methods included from Repositories::Model

included, #store

Constructor Details

#initialize(attributes = {}) ⇒ 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.

Returns a new instance of Vedeu::Geometries::Geometry.

Parameters:

  • attributes (Hash<Symbol => Boolean|Fixnum|String| Symbol|Vedeu::Geometries::Repository]) (defaults to: {})

    ttributes [Hash<Symbol => Boolean|Fixnum|String| Symbol|Vedeu::Geometries::Repository]

Options Hash (attributes):

  • client (void)
  • height (Fixnum)
  • horizontal_alignment (Symbol)
  • maximised (Boolean)
  • name (String|Symbol)
  • repository (Vedeu::Geometries::Repository)
  • vertical_alignment (Symbol)
  • width (Fixnum)
  • x (Fixnum)
  • xn (Fixnum)
  • y (Fixnum)
  • yn (Fixnum)


106
107
108
109
110
# File 'lib/vedeu/geometries/geometry.rb', line 106

def initialize(attributes = {})
  defaults.merge!(attributes).each do |key, value|
    instance_variable_set("@#{key}", value)
  end
end

Instance Attribute Details

#clientObject

Returns:

  • (Object)


46
47
48
# File 'lib/vedeu/geometries/geometry.rb', line 46

def client
  @client
end

#height=(value) ⇒ Fixnum (writeonly)

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:

  • (Fixnum)


50
51
52
# File 'lib/vedeu/geometries/geometry.rb', line 50

def height=(value)
  @height = value
end

#horizontal_alignmentSymbol

Returns:

  • (Symbol)


54
55
56
# File 'lib/vedeu/geometries/geometry.rb', line 54

def horizontal_alignment
  @horizontal_alignment
end

#maximisedBoolean Also known as: maximised?

Returns:



58
59
60
# File 'lib/vedeu/geometries/geometry.rb', line 58

def maximised
  @maximised
end

#nameNilClass|Symbol|String

Returns The name of the model, the target model or the name of the associated model.

Returns:

  • (NilClass|Symbol|String)

    The name of the model, the target model or the name of the associated model.



63
64
65
# File 'lib/vedeu/geometries/geometry.rb', line 63

def name
  @name
end

#vertical_alignmentSymbol

Returns:

  • (Symbol)


67
68
69
# File 'lib/vedeu/geometries/geometry.rb', line 67

def vertical_alignment
  @vertical_alignment
end

#width=(value) ⇒ Fixnum (writeonly)

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:

  • (Fixnum)


71
72
73
# File 'lib/vedeu/geometries/geometry.rb', line 71

def width=(value)
  @width = value
end

#x=(value) ⇒ Fixnum (writeonly)

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:

  • (Fixnum)


75
76
77
# File 'lib/vedeu/geometries/geometry.rb', line 75

def x=(value)
  @x = value
end

#xn=(value) ⇒ Fixnum (writeonly)

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:

  • (Fixnum)


79
80
81
# File 'lib/vedeu/geometries/geometry.rb', line 79

def xn=(value)
  @xn = value
end

#y=(value) ⇒ Fixnum (writeonly)

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:

  • (Fixnum)


83
84
85
# File 'lib/vedeu/geometries/geometry.rb', line 83

def y=(value)
  @y = value
end

#yn=(value) ⇒ Fixnum (writeonly)

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:

  • (Fixnum)


87
88
89
# File 'lib/vedeu/geometries/geometry.rb', line 87

def yn=(value)
  @yn = value
end

Instance Method Details

#areaVedeu::Geometries::Area (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.



186
187
188
# File 'lib/vedeu/geometries/geometry.rb', line 186

def area
  @_area ||= Vedeu::Geometries::Area.from_attributes(attributes)
end

#attributesHash<Symbol => Boolean|Fixnum|String|Symbol>

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|Fixnum|String|Symbol>)


113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/vedeu/geometries/geometry.rb', line 113

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

#defaultsHash<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.

Returns:

  • (Hash<Symbol => void>)


191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/vedeu/geometries/geometry.rb', line 191

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

#deputy(client = nil) ⇒ Vedeu::Geometries::DSL

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 DSL instance responsible for defining the DSL methods of this model.

Parameters:

  • client (Object|NilClass) (defaults to: nil)

    The client binding represents the client application object that is currently invoking a DSL method. It is required so that we can send messages to the client application object should we need to.

Returns:



138
139
140
# File 'lib/vedeu/geometries/geometry.rb', line 138

def deputy(client = nil)
  Vedeu::Geometries::DSL.new(self, client)
end

#eql?(other) ⇒ Boolean Also known as: ==

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.

An object is equal when its values are the same.

Parameters:

Returns:



146
147
148
# File 'lib/vedeu/geometries/geometry.rb', line 146

def eql?(other)
  self.class.equal?(other.class) && name == other.name
end

#maximiseVedeu::Geometries::Geometry|NilClass

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:



153
154
155
156
157
158
159
160
161
162
# File 'lib/vedeu/geometries/geometry.rb', line 153

def maximise
  return self if maximised?

  @maximised = true
  @_area     = nil

  store do
    Vedeu.trigger(:_refresh_view_, name)
  end
end

#repositoryVedeu::Geometries::Repository

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.



179
180
181
# File 'lib/vedeu/geometries/geometry.rb', line 179

def repository
  Vedeu.geometries
end

#unmaximiseVedeu::Geometries::Geometry|NilClass

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:



166
167
168
169
170
171
172
173
174
175
176
# File 'lib/vedeu/geometries/geometry.rb', line 166

def unmaximise
  return self unless maximised?

  @maximised = false
  @_area     = nil

  store do
    Vedeu.trigger(:_clear_)
    Vedeu.trigger(:_refresh_)
  end
end