Class: Uniword::TextFrame
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Uniword::TextFrame
- Defined in:
- lib/uniword/text_frame.rb
Overview
Represents a text frame for positioned text
Text frames allow precise positioning of paragraphs on the page, commonly used for sidebars, pull quotes, and floating text boxes.
Constant Summary collapse
- ANCHOR_TYPES =
Anchor types
%w[margin page text column character].freeze
- H_ALIGNMENTS =
Alignment options
%w[left center right inside outside].freeze
- V_ALIGNMENTS =
%w[top center bottom inside outside].freeze
- SIZE_RULES =
Size rules
%w[auto atLeast exact].freeze
- WRAP_TYPES =
Wrap types
%w[around none through tight].freeze
Instance Attribute Summary collapse
-
#h_alignment ⇒ String
Horizontal alignment.
-
#h_anchor ⇒ String
Horizontal anchor point.
-
#h_rule ⇒ String
Width rule (auto, atLeast, exact).
-
#height ⇒ Integer
Frame height in twips.
-
#lock_anchor ⇒ Boolean
Lock anchor position.
-
#v_alignment ⇒ String
Vertical alignment.
-
#v_anchor ⇒ String
Vertical anchor point.
-
#w_rule ⇒ String
Height rule (auto, atLeast, exact).
-
#width ⇒ Integer
Frame width in twips.
-
#wrap ⇒ String
Text wrapping style.
-
#x ⇒ Integer
Horizontal position in twips.
-
#y ⇒ Integer
Vertical position in twips.
Class Method Summary collapse
-
.absolute(width:, height:, x:, y:) ⇒ TextFrame
Create absolutely positioned frame.
-
.aligned(width:, h_alignment:, v_alignment:) ⇒ TextFrame
Create aligned frame.
Instance Method Summary collapse
-
#absolute_position? ⇒ Boolean
Check if frame uses absolute positioning.
-
#aligned_position? ⇒ Boolean
Check if frame uses alignment positioning.
-
#initialize(**attributes) ⇒ TextFrame
constructor
A new instance of TextFrame.
Constructor Details
#initialize(**attributes) ⇒ TextFrame
Returns a new instance of TextFrame.
69 70 71 72 73 74 75 |
# File 'lib/uniword/text_frame.rb', line 69 def initialize(**attributes) super validate_anchors validate_alignments validate_rules validate_wrap end |
Instance Attribute Details
#h_alignment ⇒ String
Horizontal alignment
42 43 44 |
# File 'lib/uniword/text_frame.rb', line 42 def h_alignment @h_alignment end |
#h_anchor ⇒ String
Horizontal anchor point
42 43 44 |
# File 'lib/uniword/text_frame.rb', line 42 def h_anchor @h_anchor end |
#h_rule ⇒ String
Width rule (auto, atLeast, exact)
42 43 44 |
# File 'lib/uniword/text_frame.rb', line 42 def h_rule @h_rule end |
#height ⇒ Integer
Frame height in twips
42 43 44 |
# File 'lib/uniword/text_frame.rb', line 42 def height @height end |
#lock_anchor ⇒ Boolean
Lock anchor position
42 43 44 |
# File 'lib/uniword/text_frame.rb', line 42 def lock_anchor @lock_anchor end |
#v_alignment ⇒ String
Vertical alignment
42 43 44 |
# File 'lib/uniword/text_frame.rb', line 42 def v_alignment @v_alignment end |
#v_anchor ⇒ String
Vertical anchor point
42 43 44 |
# File 'lib/uniword/text_frame.rb', line 42 def v_anchor @v_anchor end |
#w_rule ⇒ String
Height rule (auto, atLeast, exact)
42 43 44 |
# File 'lib/uniword/text_frame.rb', line 42 def w_rule @w_rule end |
#width ⇒ Integer
Frame width in twips
42 43 44 |
# File 'lib/uniword/text_frame.rb', line 42 def width @width end |
#wrap ⇒ String
Text wrapping style
42 43 44 |
# File 'lib/uniword/text_frame.rb', line 42 def wrap @wrap end |
#x ⇒ Integer
Horizontal position in twips
42 43 44 |
# File 'lib/uniword/text_frame.rb', line 42 def x @x end |
#y ⇒ Integer
Vertical position in twips
42 43 44 |
# File 'lib/uniword/text_frame.rb', line 42 def y @y end |
Class Method Details
.absolute(width:, height:, x:, y:) ⇒ TextFrame
Create absolutely positioned frame
85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/uniword/text_frame.rb', line 85 def self.absolute(width:, height:, x:, y:, **) new( width: width, height: height, x: x, y: y, h_rule: "exact", w_rule: "exact", ** ) end |
.aligned(width:, h_alignment:, v_alignment:) ⇒ TextFrame
Create aligned frame
104 105 106 107 108 109 110 111 112 |
# File 'lib/uniword/text_frame.rb', line 104 def self.aligned(width:, h_alignment:, v_alignment:, **) new( width: width, h_alignment: h_alignment, v_alignment: v_alignment, h_rule: "exact", ** ) end |
Instance Method Details
#absolute_position? ⇒ Boolean
Check if frame uses absolute positioning
117 118 119 |
# File 'lib/uniword/text_frame.rb', line 117 def absolute_position? !x.nil? && !y.nil? end |
#aligned_position? ⇒ Boolean
Check if frame uses alignment positioning
124 125 126 |
# File 'lib/uniword/text_frame.rb', line 124 def aligned_position? !h_alignment.nil? || !v_alignment.nil? end |