Class: Slideck::Alignment Private
- Inherits:
-
Object
- Object
- Slideck::Alignment
- Defined in:
- lib/slideck/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.
Responsible for accessing alignment configuration
Instance Attribute Summary collapse
-
#horizontal ⇒ String
readonly
The horizontal alignment.
-
#vertical ⇒ String
readonly
The vertical alignment.
Class Method Summary collapse
-
.[](horizontal, vertical) ⇒ Slideck::Alignment
Create an Alignment instance with an array-like initialiser.
-
.from(value, default: "center") ⇒ Slideck::Alignment
Create an Alignment instance from a string.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Determine equivalence with another object.
-
#eql?(other) ⇒ Boolean
Determine equality with another object.
-
#hash ⇒ Integer
Generate hash value of this alignment.
-
#initialize(horizontal, vertical) ⇒ Alignment
constructor
private
Create an Alignment.
-
#to_a ⇒ Array<String, String>
Convert this alignment into an array.
Constructor Details
#initialize(horizontal, vertical) ⇒ 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.
Create an Alignment
97 98 99 100 101 102 |
# File 'lib/slideck/alignment.rb', line 97 def initialize(horizontal, vertical) @horizontal = validate_horizontal(horizontal) @vertical = validate_vertical(vertical) freeze end |
Instance Attribute Details
#horizontal ⇒ String (readonly)
The horizontal alignment
72 73 74 |
# File 'lib/slideck/alignment.rb', line 72 def horizontal @horizontal end |
#vertical ⇒ String (readonly)
The vertical alignment
82 83 84 |
# File 'lib/slideck/alignment.rb', line 82 def vertical @vertical end |
Class Method Details
.[](horizontal, vertical) ⇒ Slideck::Alignment
Create an Alignment instance with an array-like initialiser
60 61 62 |
# File 'lib/slideck/alignment.rb', line 60 def self.[](horizontal, vertical) new(horizontal, vertical) end |
.from(value, default: "center") ⇒ Slideck::Alignment
Create an Alignment instance from a string
40 41 42 43 44 45 |
# File 'lib/slideck/alignment.rb', line 40 def self.from(value, default: "center") horizontal, vertical = *value.split(/[ ,]+/) vertical = default if vertical.nil? new(horizontal, vertical) end |
Instance Method Details
#==(other) ⇒ Boolean
Determine equivalence with another object
117 118 119 120 |
# File 'lib/slideck/alignment.rb', line 117 def ==(other) other.is_a?(self.class) && horizontal == other.horizontal && vertical == other.vertical end |
#eql?(other) ⇒ Boolean
Determine equality with another object
134 135 136 137 |
# File 'lib/slideck/alignment.rb', line 134 def eql?(other) instance_of?(other.class) && horizontal.eql?(other.horizontal) && vertical.eql?(other.vertical) end |
#hash ⇒ Integer
Generate hash value of this alignment
147 148 149 |
# File 'lib/slideck/alignment.rb', line 147 def hash [self.class, horizontal, vertical].hash end |
#to_a ⇒ Array<String, String>
Convert this alignment into an array
159 160 161 |
# File 'lib/slideck/alignment.rb', line 159 def to_a [horizontal, vertical] end |