Class: PdftkForms::Field
- Inherits:
-
Object
- Object
- PdftkForms::Field
- Defined in:
- lib/pdftk_forms/field.rb
Overview
Represents a fillable form field on a particular PDF
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
Class Method Summary collapse
Instance Method Summary collapse
- #check_box? ⇒ Boolean
- #field_type ⇒ Object
-
#initialize(attributes) ⇒ Field
constructor
A new instance of Field.
- #multiline? ⇒ Boolean
- #push_button? ⇒ Boolean
- #radio_button? ⇒ Boolean
- #required? ⇒ Boolean
Constructor Details
#initialize(attributes) ⇒ Field
Returns a new instance of Field.
7 8 9 |
# File 'lib/pdftk_forms/field.rb', line 7 def initialize(attributes) @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/pdftk_forms/field.rb', line 5 def attributes @attributes end |
Class Method Details
.alias_attribute(method_name, attribute_name) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/pdftk_forms/field.rb', line 49 def self.alias_attribute method_name, attribute_name define_method(method_name) do attributes[attribute_name] end define_method("#{method_name}=") do |value| attributes[attribute_name] = value end end |
Instance Method Details
#check_box? ⇒ Boolean
27 28 29 |
# File 'lib/pdftk_forms/field.rb', line 27 def check_box? self.type == 'Button' && ! && ! end |
#field_type ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/pdftk_forms/field.rb', line 31 def field_type if self.type == 'Button' if 'push_button' elsif 'radio_button' else 'check_box' end elsif self.type == 'Text' multiline? ? 'text_area' : 'text_field' elsif self.type == 'Choice' 'select' else self.type.downcase end end |
#multiline? ⇒ Boolean
15 16 17 |
# File 'lib/pdftk_forms/field.rb', line 15 def multiline? self.type == 'Text' && check_bit_true(4096, 13) end |
#push_button? ⇒ Boolean
19 20 21 |
# File 'lib/pdftk_forms/field.rb', line 19 def self.type == 'Button' && check_bit_true(65536, 17) end |
#radio_button? ⇒ Boolean
23 24 25 |
# File 'lib/pdftk_forms/field.rb', line 23 def self.type == 'Button' && ! && check_bit_true(32768, 16) end |
#required? ⇒ Boolean
11 12 13 |
# File 'lib/pdftk_forms/field.rb', line 11 def required? check_bit_true(2, 2) end |