Skip to content

Commit

Permalink
store and manipulate last_value directly
Browse files Browse the repository at this point in the history
  • Loading branch information
jkraemer committed Aug 29, 2016
1 parent 349c675 commit 31a7cce
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/pdf_forms/field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Field
#
# Represenation of a PDF Form Field
def initialize(field_description)
previous_key = nil
last_value = nil
field_description.each_line do |line|
case line
when /FieldStateOption:\s*(.*?)\s*$/
Expand All @@ -29,14 +29,11 @@ def initialize(field_description)
proc = Proc.new { instance_variable_get("@#{key}".to_sym) }
self.class.send(:define_method, key.to_sym, proc)
end
previous_key = key
last_value = value
else
# pdftk returns a line that doesn't start with "Field"
# It happens when a text field has multiple lines
key = previous_key
last_value = instance_variable_get("@#{key}")
new_value = last_value + "\n" + line # Linux line ending
instance_variable_set("@#{key}", new_value)
last_value << "\n" << line
end
end
end
Expand Down

0 comments on commit 31a7cce

Please sign in to comment.