lib/origami/acroform.rb in origami-2.0.1 vs lib/origami/acroform.rb in origami-2.0.2

- old
+ new

@@ -65,19 +65,19 @@ # # Iterates over each Acroform Field. # def each_field return enum_for(__method__) do - if self.form? and self.Catalog.AcroForm[:Fields].is_a?(Array) - self.Catalog.AcroForm[:Fields].length + if self.form? and self.Catalog.AcroForm.Fields.is_a?(Array) + self.Catalog.AcroForm.Fields.length else 0 end end unless block_given? - if self.form? and self.Catalog.AcroForm[:Fields].is_a?(Array) - self.Catalog.AcroForm[:Fields].each do |field| + if self.form? and self.Catalog.AcroForm.Fields.is_a?(Array) + self.Catalog.AcroForm.Fields.each do |field| yield(field.solve) end end end @@ -86,10 +86,12 @@ # def get_field(name) self.each_field do |field| return field if field[:T].solve == name end + + nil end end # # Class representing a interactive form Dictionary. @@ -168,12 +170,36 @@ receiver.field :DS, :Type => String, :Version => "1.5" receiver.field :RV, :Type => [ String, Stream ], :Version => "1.5" end def pre_build #:nodoc: - self.T ||= "undef#{::Array.new(5) {('0'.ord + rand(10)).chr}.join}" + unless self.key?(:T) + self.set_name "field#{self.object_id}" + end super + end + + # + # Sets the (partial) name of the field. + # + def set_name(field_name) + self.T = field_name + self + end + + # + # Sets the (partial) name of the field. + # + def name=(field_name) + self.T = field_name + end + + # + # Returns the (partial) name of the field. + # + def name + self.T end def onKeyStroke(action) unless action.is_a?(Action) raise TypeError, "An Action object must be passed."