Class: PdfForms::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf_forms/field.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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*$/
      (@options ||= []) << $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

#flagsObject (readonly)

Common Fields



34
35
36
# File 'lib/pdf_forms/field.rb', line 34

def flags
  @flags
end

#justificationObject (readonly)

Common Fields



34
35
36
# File 'lib/pdf_forms/field.rb', line 34

def justification
  @justification
end

#nameObject (readonly)

Common Fields



34
35
36
# File 'lib/pdf_forms/field.rb', line 34

def name
  @name
end

#optionsObject (readonly)

Common Fields



34
35
36
# File 'lib/pdf_forms/field.rb', line 34

def options
  @options
end

#typeObject (readonly)

Common Fields



34
35
36
# File 'lib/pdf_forms/field.rb', line 34

def type
  @type
end

#valueObject (readonly)

Common Fields



34
35
36
# File 'lib/pdf_forms/field.rb', line 34

def value
  @value
end

#valuedefaultObject (readonly)

Common Fields



34
35
36
# File 'lib/pdf_forms/field.rb', line 34

def valuedefault
  @valuedefault
end