Class: PDFRavager::Template
- Inherits:
-
Object
- Object
- PDFRavager::Template
- Defined in:
- lib/pdf_ravager/template.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#strategy ⇒ Object
readonly
Returns the value of attribute strategy.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #check(name, opts = {}) ⇒ Object
- #checkbox_group(group_name, &blk) ⇒ Object
- #fill(group_name, name) ⇒ Object
-
#initialize(opts = {}) {|_self| ... } ⇒ Template
constructor
A new instance of Template.
- #radio_group(group_name, &blk) ⇒ Object
- #ravage(file, opts = {}) ⇒ Object
- #rich_text(name, value) ⇒ Object
- #text(name, value) ⇒ Object
- #uncheck(name, opts = {}) ⇒ Object
Constructor Details
#initialize(opts = {}) {|_self| ... } ⇒ Template
Returns a new instance of Template.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/pdf_ravager/template.rb', line 14 def initialize(opts={}) opts = {:name => opts} if opts.respond_to?(:to_sym) unless opts[:name].nil? warn "[DEPRECATION] Passing a name to `PDFRavager::Template.new` " + "is deprecated and will be removed in 1.0.0" end @name, @strategy = opts[:name], (opts[:strategy] || :smart) unless [:smart, :acro_forms, :xfa].include?(@strategy) raise "Bad strategy '#{@strategy}'" end @fields = [] yield self if block_given? end |
Instance Attribute Details
#fields ⇒ Object
Returns the value of attribute fields.
12 13 14 |
# File 'lib/pdf_ravager/template.rb', line 12 def fields @fields end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/pdf_ravager/template.rb', line 11 def name @name end |
#strategy ⇒ Object (readonly)
Returns the value of attribute strategy.
11 12 13 |
# File 'lib/pdf_ravager/template.rb', line 11 def strategy @strategy end |
Instance Method Details
#==(other) ⇒ Object
66 67 68 |
# File 'lib/pdf_ravager/template.rb', line 66 def ==(other) self.fields == other.fields end |
#check(name, opts = {}) ⇒ Object
36 37 38 |
# File 'lib/pdf_ravager/template.rb', line 36 def check(name, opts={}) @fields << PDFRavager::Fields::Checkbox.new(name, true, opts) end |
#checkbox_group(group_name, &blk) ⇒ Object
48 49 50 |
# File 'lib/pdf_ravager/template.rb', line 48 def checkbox_group(group_name, &blk) PDFRavager::Fieldsets::CheckboxGroup.new(self, group_name, &blk) end |
#fill(group_name, name) ⇒ Object
44 45 46 |
# File 'lib/pdf_ravager/template.rb', line 44 def fill(group_name, name) @fields << PDFRavager::Fields::Radio.new(group_name, name) end |
#radio_group(group_name, &blk) ⇒ Object
52 53 54 |
# File 'lib/pdf_ravager/template.rb', line 52 def radio_group(group_name, &blk) PDFRavager::Fieldsets::RadioGroup.new(self, group_name, &blk) end |
#ravage(file, opts = {}) ⇒ Object
57 58 59 |
# File 'lib/pdf_ravager/template.rb', line 57 def ravage(file, opts={}) PDFRavager::Ravager.new(self, opts.merge({:in_file => file})).ravage end |
#rich_text(name, value) ⇒ Object
32 33 34 |
# File 'lib/pdf_ravager/template.rb', line 32 def rich_text(name, value) @fields << PDFRavager::Fields::RichText.new(name, value) end |
#text(name, value) ⇒ Object
28 29 30 |
# File 'lib/pdf_ravager/template.rb', line 28 def text(name, value) @fields << PDFRavager::Fields::Text.new(name, value) end |
#uncheck(name, opts = {}) ⇒ Object
40 41 42 |
# File 'lib/pdf_ravager/template.rb', line 40 def uncheck(name, opts={}) @fields << PDFRavager::Fields::Checkbox.new(name, false, opts) end |