Class: Vedeu::Geometry::Alignment Private

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/geometry/alignment.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.

The subclasses of this class, HorizontalAlignment and VerticalAlignment provide the mechanism to align an interface or view horizontally or vertically within the available terminal space.

Direct Known Subclasses

HorizontalAlignment, VerticalAlignment

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value = nil) ⇒ Vedeu::Geometry::Alignment

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::Geometry::Alignment.

Parameters:

  • value (NilClass|Symbol) (defaults to: nil)


42
43
44
# File 'lib/vedeu/geometry/alignment.rb', line 42

def initialize(value = nil)
  @value = value
end

Class Method Details

.align(value = nil) ⇒ 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.

Parameters:

  • value (NilClass|Symbol) (defaults to: nil)


19
20
21
# File 'lib/vedeu/geometry/alignment.rb', line 19

def self.align(value = nil)
  new(value).align
end

.coerce(value = nil) ⇒ Vedeu::Geometry::Alignment

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.

Parameters:

Returns:



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/vedeu/geometry/alignment.rb', line 25

def self.coerce(value = nil)
  if value.is_a?(self)
    value

  elsif value.is_a?(Symbol)
    new(value)

  else
    new(:none)

  end
end

Instance Method Details

#alignObject

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.

Raises:



48
49
50
# File 'lib/vedeu/geometry/alignment.rb', line 48

def align
  fail Vedeu::Error::NotImplemented, 'Subclasses implement this.'.freeze
end

#bottom_aligned?Boolean

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.

Return a boolean indicating alignment was set to :bottom.

Returns:

  • (Boolean)


55
56
57
# File 'lib/vedeu/geometry/alignment.rb', line 55

def bottom_aligned?
  value == :bottom
end

#centre_aligned?Boolean

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.

Return a boolean indicating alignment was set to :centre.

Returns:

  • (Boolean)


62
63
64
# File 'lib/vedeu/geometry/alignment.rb', line 62

def centre_aligned?
  value == :centre
end

#left_aligned?Boolean

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.

Return a boolean indicating alignment was set to :left.

Returns:

  • (Boolean)


69
70
71
# File 'lib/vedeu/geometry/alignment.rb', line 69

def left_aligned?
  value == :left
end

#middle_aligned?Boolean

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.

Return a boolean indicating alignment was set to :middle.

Returns:

  • (Boolean)


76
77
78
# File 'lib/vedeu/geometry/alignment.rb', line 76

def middle_aligned?
  value == :middle
end

#none?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.

Returns:

  • (Boolean)


104
105
106
# File 'lib/vedeu/geometry/alignment.rb', line 104

def none?
  @value == :none || @value.nil? || !(@value.is_a?(Symbol))
end

#right_aligned?Boolean

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.

Return a boolean indicating alignment was set to :right.

Returns:

  • (Boolean)


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

def right_aligned?
  value == :right
end

#top_aligned?Boolean

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.

Return a boolean indicating alignment was set to :top.

Returns:

  • (Boolean)


90
91
92
# File 'lib/vedeu/geometry/alignment.rb', line 90

def top_aligned?
  value == :top
end

#unaligned?Boolean

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.

Return a boolean indicating alignment was set to, or is :none.

Returns:

  • (Boolean)


97
98
99
# File 'lib/vedeu/geometry/alignment.rb', line 97

def unaligned?
  value == :none
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.

Returns:

  • (Boolean)


109
110
111
# File 'lib/vedeu/geometry/alignment.rb', line 109

def valid?
  values.include?(value)
end

#valueSymbol (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:

  • (Symbol)


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

def value
  @_value ||= if none?
                :none

              elsif @value == :center
                :centre

              else
                @value.to_sym

              end
end

#valuesArray<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:

  • (Array<Symbol>)


128
129
130
131
132
133
134
135
136
137
138
# File 'lib/vedeu/geometry/alignment.rb', line 128

def values
  [
    :bottom,
    :centre,
    :left,
    :middle,
    :none,
    :right,
    :top,
  ]
end