Class: Arrolio::WritingMode
- Inherits:
-
Object
- Object
- Arrolio::WritingMode
- Defined in:
- lib/arrolio/writing_mode.rb
Overview
Writing mode enumeration for vertical/RTL layout. Controls the inline and block progression directions used by the layout engine. The values map to XSL-FO writing-mode property values.
LR_TB — left-to-right inline, top-to-bottom block (Latin, CJK).
RL_TB — right-to-left inline, top-to-bottom block (Arabic, Hebrew).
TB_RL — top-to-bottom inline, right-to-left block (vertical CJK).
Constant Summary collapse
Instance Attribute Summary collapse
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
-
#block_direction ⇒ Object
Returns the block progression direction as a 2D vector.
- #hash ⇒ Object
-
#initialize(mode = DEFAULT) ⇒ WritingMode
constructor
A new instance of WritingMode.
-
#inline_direction ⇒ Object
Returns the inline progression direction as a 2D vector.
- #ltr? ⇒ Boolean
- #rtl? ⇒ Boolean
- #vertical? ⇒ Boolean
Constructor Details
#initialize(mode = DEFAULT) ⇒ WritingMode
Returns a new instance of WritingMode.
22 23 24 25 |
# File 'lib/arrolio/writing_mode.rb', line 22 def initialize(mode = DEFAULT) @mode = mode.to_sym freeze end |
Instance Attribute Details
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
20 21 22 |
# File 'lib/arrolio/writing_mode.rb', line 20 def mode @mode end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
57 58 59 |
# File 'lib/arrolio/writing_mode.rb', line 57 def ==(other) other.is_a?(self.class) && mode == other.mode end |
#block_direction ⇒ Object
Returns the block progression direction as a 2D vector.
50 51 52 53 54 55 |
# File 'lib/arrolio/writing_mode.rb', line 50 def block_direction case @mode when LR_TB, RL_TB then [0, -1] when TB_RL then [-1, 0] end end |
#hash ⇒ Object
62 63 64 |
# File 'lib/arrolio/writing_mode.rb', line 62 def hash [self.class, mode].hash end |
#inline_direction ⇒ Object
Returns the inline progression direction as a 2D vector.
[1, 0] = rightward, [-1, 0] = leftward, [0, 1] = downward.
41 42 43 44 45 46 47 |
# File 'lib/arrolio/writing_mode.rb', line 41 def inline_direction case @mode when LR_TB then [1, 0] when RL_TB then [-1, 0] when TB_RL then [0, 1] end end |
#vertical? ⇒ Boolean
27 28 29 |
# File 'lib/arrolio/writing_mode.rb', line 27 def vertical? @mode == TB_RL end |