Class: Vedeu::Geometry::Alignment
- Inherits:
-
Object
- Object
- Vedeu::Geometry::Alignment
- Defined in:
- lib/vedeu/geometry/alignment.rb
Overview
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
Class Method Summary collapse
Instance Method Summary collapse
- #align ⇒ Object
-
#bottom_aligned? ⇒ Boolean
Return a boolean indicating alignment was set to :bottom.
-
#centre_aligned? ⇒ Boolean
Return a boolean indicating alignment was set to :centre.
- #initialize(value = nil) ⇒ Vedeu::Geometry::Alignment constructor
-
#left_aligned? ⇒ Boolean
Return a boolean indicating alignment was set to :left.
-
#middle_aligned? ⇒ Boolean
Return a boolean indicating alignment was set to :middle.
- #none? ⇒ Boolean private
-
#right_aligned? ⇒ Boolean
Return a boolean indicating alignment was set to :right.
-
#top_aligned? ⇒ Boolean
Return a boolean indicating alignment was set to :top.
-
#unaligned? ⇒ Boolean
Return a boolean indicating alignment was set to, or is :none.
- #valid? ⇒ Boolean private
- #value ⇒ Symbol private
- #values ⇒ Array<Symbol> private
Constructor Details
#initialize(value = nil) ⇒ Vedeu::Geometry::Alignment
38 39 40 |
# File 'lib/vedeu/geometry/alignment.rb', line 38 def initialize(value = nil) @value = value end |
Class Method Details
.align(value = nil) ⇒ Object
17 18 19 |
# File 'lib/vedeu/geometry/alignment.rb', line 17 def self.align(value = nil) new(value).align end |
.coerce(value = nil) ⇒ Vedeu::Geometry::Alignment
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vedeu/geometry/alignment.rb', line 23 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
#align ⇒ Object
44 45 46 |
# File 'lib/vedeu/geometry/alignment.rb', line 44 def align fail Vedeu::Error::NotImplemented, 'Subclasses implement this.'.freeze end |
#bottom_aligned? ⇒ Boolean
Return a boolean indicating alignment was set to :bottom.
51 52 53 |
# File 'lib/vedeu/geometry/alignment.rb', line 51 def bottom_aligned? value == :bottom end |
#centre_aligned? ⇒ Boolean
Return a boolean indicating alignment was set to :centre.
58 59 60 |
# File 'lib/vedeu/geometry/alignment.rb', line 58 def centre_aligned? value == :centre end |
#left_aligned? ⇒ Boolean
Return a boolean indicating alignment was set to :left.
65 66 67 |
# File 'lib/vedeu/geometry/alignment.rb', line 65 def left_aligned? value == :left end |
#middle_aligned? ⇒ Boolean
Return a boolean indicating alignment was set to :middle.
72 73 74 |
# File 'lib/vedeu/geometry/alignment.rb', line 72 def middle_aligned? value == :middle end |
#none? ⇒ Boolean (private)
100 101 102 |
# File 'lib/vedeu/geometry/alignment.rb', line 100 def none? @value == :none || @value.nil? || !(@value.is_a?(Symbol)) end |
#right_aligned? ⇒ Boolean
Return a boolean indicating alignment was set to :right.
79 80 81 |
# File 'lib/vedeu/geometry/alignment.rb', line 79 def right_aligned? value == :right end |
#top_aligned? ⇒ Boolean
Return a boolean indicating alignment was set to :top.
86 87 88 |
# File 'lib/vedeu/geometry/alignment.rb', line 86 def top_aligned? value == :top end |
#unaligned? ⇒ Boolean
Return a boolean indicating alignment was set to, or is :none.
93 94 95 |
# File 'lib/vedeu/geometry/alignment.rb', line 93 def unaligned? value == :none end |
#valid? ⇒ Boolean (private)
105 106 107 |
# File 'lib/vedeu/geometry/alignment.rb', line 105 def valid? values.include?(value) end |
#value ⇒ Symbol (private)
110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/vedeu/geometry/alignment.rb', line 110 def value @_value ||= if none? :none elsif @value == :center :centre else @value.to_sym end end |
#values ⇒ Array<Symbol> (private)
124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/vedeu/geometry/alignment.rb', line 124 def values [ :bottom, :centre, :left, :middle, :none, :right, :top, ] end |