Class: Arrolio::Content::FormField
- Inherits:
-
Object
- Object
- Arrolio::Content::FormField
- Defined in:
- lib/arrolio/content/form_field.rb
Overview
A form field for interactive PDF AcroForm. Carries the field type, name, value, and geometry. The renderer emits it as a PDAcroForm widget (text field, checkbox, radio button) during post-processing. This model captures the semantic intent; the actual PDF widget creation is a renderer post-pass.
Constant Summary collapse
- TYPES =
%i[text checkbox radio signature].freeze
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#page_number ⇒ Object
readonly
Returns the value of attribute page_number.
-
#style_id ⇒ Object
readonly
Returns the value of attribute style_id.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #checkbox? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(type:, name:, page_number:, x:, y:, width:, height:, value: nil, style_id: :form_field) ⇒ FormField
constructor
A new instance of FormField.
- #radio? ⇒ Boolean
- #text? ⇒ Boolean
Constructor Details
#initialize(type:, name:, page_number:, x:, y:, width:, height:, value: nil, style_id: :form_field) ⇒ FormField
Returns a new instance of FormField.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/arrolio/content/form_field.rb', line 16 def initialize(type:, name:, page_number:, x:, y:, width:, height:, value: nil, style_id: :form_field) @type = type.to_sym @name = name.to_s @value = value @page_number = page_number.to_i @x = x.to_f @y = y.to_f @width = width.to_f @height = height.to_f @style_id = style_id.to_sym freeze end |
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
13 14 15 |
# File 'lib/arrolio/content/form_field.rb', line 13 def height @height end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/arrolio/content/form_field.rb', line 13 def name @name end |
#page_number ⇒ Object (readonly)
Returns the value of attribute page_number.
13 14 15 |
# File 'lib/arrolio/content/form_field.rb', line 13 def page_number @page_number end |
#style_id ⇒ Object (readonly)
Returns the value of attribute style_id.
13 14 15 |
# File 'lib/arrolio/content/form_field.rb', line 13 def style_id @style_id end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
13 14 15 |
# File 'lib/arrolio/content/form_field.rb', line 13 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
13 14 15 |
# File 'lib/arrolio/content/form_field.rb', line 13 def value @value end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
13 14 15 |
# File 'lib/arrolio/content/form_field.rb', line 13 def width @width end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
13 14 15 |
# File 'lib/arrolio/content/form_field.rb', line 13 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
13 14 15 |
# File 'lib/arrolio/content/form_field.rb', line 13 def y @y end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
33 34 35 36 37 38 39 |
# File 'lib/arrolio/content/form_field.rb', line 33 def ==(other) other.is_a?(self.class) && type == other.type && name == other.name && value == other.value && page_number == other.page_number && x == other.x && y == other.y && width == other.width && height == other.height end |
#checkbox? ⇒ Boolean
30 |
# File 'lib/arrolio/content/form_field.rb', line 30 def checkbox? = @type == :checkbox |
#hash ⇒ Object
42 43 44 |
# File 'lib/arrolio/content/form_field.rb', line 42 def hash [self.class, type, name, value, page_number, x, y, width, height].hash end |
#radio? ⇒ Boolean
31 |
# File 'lib/arrolio/content/form_field.rb', line 31 def radio? = @type == :radio |
#text? ⇒ Boolean
29 |
# File 'lib/arrolio/content/form_field.rb', line 29 def text? = @type == :text |