Class: PdfForms::Field
- Inherits:
-
Object
- Object
- PdfForms::Field
- Defined in:
- lib/pdf_forms/field.rb
Instance Attribute Summary collapse
-
#flags ⇒ Object
readonly
Common Fields.
-
#justification ⇒ Object
readonly
Common Fields.
-
#name ⇒ Object
readonly
Common Fields.
-
#options ⇒ Object
readonly
Common Fields.
-
#type ⇒ Object
readonly
Common Fields.
-
#value ⇒ Object
readonly
Common Fields.
-
#valuedefault ⇒ Object
readonly
Common Fields.
Instance Method Summary collapse
-
#initialize(field_description) ⇒ Field
constructor
FieldType: Button FieldName: Sprachoptionen_Inverssuche_Widerspruch FieldFlags: 0 FieldJustification: Left FieldStateOption: Ja FieldStateOption: Off.
Constructor Details
#initialize(field_description) ⇒ Field
FieldType: Button FieldName: Sprachoptionen_Inverssuche_Widerspruch FieldFlags: 0 FieldJustification: Left FieldStateOption: Ja FieldStateOption: Off
Represenation of a PDF Form Field
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pdf_forms/field.rb', line 14 def initialize(field_description) field_description.each_line do |line| case line when /FieldStateOption:\s*(.*?)\s*$/ ( ||= []) << $1 else if match = line.match(/^\s*(?<key>[^:]+):\s*(?<value>.*)$/) key = match[:key].to_s.strip value = match[:value].to_s var_name = key.gsub(/Field/, '').downcase unless self.respond_to?(var_name) self.class.send(:define_method, var_name.to_sym, Proc.new{ instance_variable_get("@#{var_name}".to_sym) } ) # in case new or unknown fields crop up... end instance_variable_set("@#{key.gsub(/Field/, '').downcase}".to_sym, value) end end end end |
Instance Attribute Details
#flags ⇒ Object (readonly)
Common Fields
34 35 36 |
# File 'lib/pdf_forms/field.rb', line 34 def flags @flags end |
#justification ⇒ Object (readonly)
Common Fields
34 35 36 |
# File 'lib/pdf_forms/field.rb', line 34 def justification @justification end |
#name ⇒ Object (readonly)
Common Fields
34 35 36 |
# File 'lib/pdf_forms/field.rb', line 34 def name @name end |
#options ⇒ Object (readonly)
Common Fields
34 35 36 |
# File 'lib/pdf_forms/field.rb', line 34 def end |
#type ⇒ Object (readonly)
Common Fields
34 35 36 |
# File 'lib/pdf_forms/field.rb', line 34 def type @type end |
#value ⇒ Object (readonly)
Common Fields
34 35 36 |
# File 'lib/pdf_forms/field.rb', line 34 def value @value end |
#valuedefault ⇒ Object (readonly)
Common Fields
34 35 36 |
# File 'lib/pdf_forms/field.rb', line 34 def valuedefault @valuedefault end |