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
# 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
      key, value = line.chomp.split(':').map(&:strip)
      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

Instance Attribute Details

#flagsObject (readonly)

Common Fields



31
32
33
# File 'lib/pdf_forms/field.rb', line 31

def flags
  @flags
end

#justificationObject (readonly)

Common Fields



31
32
33
# File 'lib/pdf_forms/field.rb', line 31

def justification
  @justification
end

#nameObject (readonly)

Common Fields



31
32
33
# File 'lib/pdf_forms/field.rb', line 31

def name
  @name
end

#optionsObject (readonly)

Common Fields



31
32
33
# File 'lib/pdf_forms/field.rb', line 31

def options
  @options
end

#typeObject (readonly)

Common Fields



31
32
33
# File 'lib/pdf_forms/field.rb', line 31

def type
  @type
end

#valueObject (readonly)

Common Fields



31
32
33
# File 'lib/pdf_forms/field.rb', line 31

def value
  @value
end

#valuedefaultObject (readonly)

Common Fields



31
32
33
# File 'lib/pdf_forms/field.rb', line 31

def valuedefault
  @valuedefault
end